Repository: rauchg/wifi-password Branch: master Commit: d17a0dd80846 Files: 5 Total size: 3.7 KB Directory structure: gitextract_t8lccz_i/ ├── History.md ├── Readme.md ├── package.json ├── wifi-password.plugin.zsh └── wifi-password.sh ================================================ FILE CONTENTS ================================================ ================================================ FILE: History.md ================================================ 0.1.0 / 2015-02-14 ================== * default to `quiet` when piping (non-tty) 0.0.1 / 2015-02-14 ================== * initial release ================================================ FILE: Readme.md ================================================ # wifi-password People ask you for the Wi-Fi password. Answer quickly. **macOS only**. [Windows version](https://github.com/RReverser/WiFi-Password). ![](https://i.cloudup.com/uUo8iSbKXRh/km6iJT.gif) ## How to use **1. Install it** With [bpkg](https://github.com/bpkg/bpkg): ``` $ bpkg install rauchg/wifi-password ``` With [Homebrew](https://github.com/Homebrew/homebrew): ``` $ brew install wifi-password ``` With [Antigen](https://github.com/zsh-users/antigen): Add `antigen bundle rauchg/wifi-password` to your `.zshrc` with your other antigen commands With [Zgen](https://github.com/tarjoilija/zgen) Add `zgen load rauchg/wifi-password` to your `.zshrc` with your other zgen commands or with `curl`: ``` curl -L https://raw.github.com/rauchg/wifi-password/master/wifi-password.sh -o ~/bin/wifi-password && chmod +x ~/bin/wifi-password ``` If you don't have `~/bin` in your `$PATH`, replace it with `/usr/local/bin` or similar. **2. Use it:** To get the password for the WiFi you're currently logged onto: ``` $ wifi-password ``` To get it for a specific SSID: ``` $ wifi-password ``` To put it straight in your clipboard for pasting elsewhere (OS X only): ``` $ wifi-password | pbcopy ``` ## License MIT ================================================ FILE: package.json ================================================ { "name": "wifi-password", "version": "0.1.0", "description": "People ask you for the Wi-Fi password. Answer quickly.", "global": "1", "install": "install -b wifi-password.sh ${PREFIX:-/usr/local}/bin/wifi-password", "scripts": [ "wifi-password.sh" ] } ================================================ FILE: wifi-password.plugin.zsh ================================================ # This plugin is MIT licensed. # # Make git-open easy to install and keep up to date if you're using a # ZSH framework like Zgen or Antigen export PATH=$(dirname $0):${PATH} ================================================ FILE: wifi-password.sh ================================================ #!/usr/bin/env sh version="0.1.0" # locate airport(1) airport="/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport" if [ ! -f $airport ]; then echo "ERROR: Can't find \`airport\` CLI program at \"$airport\"." exit 1 fi # by default we are verbose (unless non-tty) if [ -t 1 ]; then verbose=1 else verbose= fi # usage info usage() { cat <&2 exit 1 fi fi # warn user about keychain dialog if [ $verbose ]; then echo "" echo "\033[90m … getting password for \"$ssid\". \033[39m" echo "\033[90m … keychain prompt incoming. \033[39m" fi sleep 2 # source: http://blog.macromates.com/2006/keychain-access-from-shell/ pwd="`security find-generic-password -D 'AirPort network password' -ga \"$ssid\" 2>&1 >/dev/null`" if [[ $pwd =~ "could" ]]; then echo "ERROR: Could not find SSID \"$ssid\"" >&2 exit 1 fi # clean up password pwd=$(echo "$pwd" | sed -e "s/^.*\"\(.*\)\".*$/\1/") if [ "" == "$pwd" ]; then echo "ERROR: Could not get password. Did you enter your Keychain credentials?" >&2 exit 1 fi # print if [ $verbose ]; then echo "\033[96m ✓ \"$pwd\" \033[39m" echo "" else echo $pwd fi