We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ecb13d7 commit 40f46e8Copy full SHA for 40f46e8
bin/wifi-pass
@@ -2,11 +2,13 @@
2
3
set -e
4
5
-ssid="$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | sed -n "/ SSID:/s/^.\\{2,\\}: //p")"
+wifi_interface=$(networksetup -listallhardwareports | awk '/Wi-Fi|AirPort/{getline; print $NF}')
6
+ssid=$(ipconfig getsummary "$wifi_interface" | awk -F ' SSID : ' '/ SSID : / {print $2}')
7
+
8
if [ -n "$ssid" ]; then
9
pw=$(sudo security find-generic-password -ga "$ssid" 2>&1 >/dev/null | cut -d\" -f2)
10
echo "Password for \"${ssid}\": ${pw}"
11
else
- echo "No current wifi network name detected" >&2
12
+ echo "No current Wi-Fi network name detected" >&2
13
exit 1
14
fi
0 commit comments