Skip to content

Instantly share code, notes, and snippets.

@tjluoma
Created April 20, 2015 15:25
Show Gist options
  • Select an option

  • Save tjluoma/9d31594acf6296895871 to your computer and use it in GitHub Desktop.

Select an option

Save tjluoma/9d31594acf6296895871 to your computer and use it in GitHub Desktop.
Show a Mac’s current SSID (Wi-Fi network)
#!/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