Skip to content

Instantly share code, notes, and snippets.

@kvbik
Last active March 18, 2024 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kvbik/2f90a73d3acd9fb1ef4d2a45c5f9cfe8 to your computer and use it in GitHub Desktop.
Save kvbik/2f90a73d3acd9fb1ef4d2a45c5f9cfe8 to your computer and use it in GitHub Desktop.
#!/bin/bash
# git clone https://gist.github.com/kvbik/2f90a73d3acd9fb1ef4d2a45c5f9cfe8
# current macos wifi connection, thx to
# https://apple.stackexchange.com/questions/81221/how-do-i-get-wi-fi-info-from-within-terminal
W=$(
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | \
sed -n '/^[ ]*SSID: / s/^[ ]*SSID: //p'
)
# current macos wifi password, thx to
# https://www.labnol.org/software/find-wi-fi-network-password/28949/
P=$(
security find-generic-password -wa "$W"
)
echo "$W" >/dev/stderr
echo "$P" >/dev/stderr
# you really want to avoid the \n in the QR code
echo -n "$P" | qr # pip install qrcode
security find-generic-password -wa "$(
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | \
sed -n '/^[ ]*SSID: / s/^[ ]*SSID: //p'
)" | tee /dev/stderr | head -n1 | while read pwd; do echo -n $pwd | qr; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment