-
-
Save Kabouik/a114d97bcfbdc2db5dd939f7320cb8e6 to your computer and use it in GitHub Desktop.
Connect to Wifi networks using network manager listed by fzf
This file contains 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
wl(){ | |
local ssid | |
local conn | |
nmcli device wifi rescan > /dev/null | |
ssid=$(nmcli device wifi list | tail -n +2 | grep -v '^ *\B--\B' | fzf -m | sed 's/^ *\*//' | awk '{print $1}') | |
if [ "x$ssid" != "x" ]; then | |
# check if the SSID has already a connection setup | |
conn=$(nmcli con | grep "$ssid" | awk '{print $1}' | uniq) | |
if [ "x$conn" = "x$ssid" ]; then | |
echo "Please wait while switching to known network $ssid…" | |
# if yes, bring up that connection | |
nmcli con up id "$conn" | |
else | |
echo "Please wait while connecting to new network $ssid…" | |
# if not connect to it and ask for the password | |
nmcli device wifi connect "$ssid" | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment