Created
April 20, 2015 15:25
-
-
Save tjluoma/9d31594acf6296895871 to your computer and use it in GitHub Desktop.
Show a Mac’s current SSID (Wi-Fi network)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/zsh -f | |
| # Purpose: Show the SSID (name of currently connected Wi-Fi network) | |
| # Intended to be used with TextBar - http://www.richsomerfield.com/apps/ | |
| if [ ! -x '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport' ] | |
| then | |
| echo "airport command not found" | |
| exit 0 | |
| fi | |
| # This will work with SSIDs which have spaces in the filenames | |
| SSID=$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I 2>/dev/null \ | |
| | awk -F': ' '/ SSID/{print $NF}') | |
| if [[ "$SSID" == "" ]] | |
| then | |
| # No SSID was found | |
| echo "(No SSID found)" | |
| else | |
| echo "$SSID" | |
| fi | |
| exit 0 | |
| # | |
| # | |
| # From: Tj Luo.ma | |
| # Mail: luomat at gmail dot com | |
| # Web: http://RhymesWithDiploma.com | |
| # Date: 2015-04-18 | |
| #EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment