#! /bin/zsh [[ $(uname) == "SunOS" ]] && return WIFI_IF=$(iw dev | grep Interface | cut -d ' ' -f 2) # e.g., wlan0 WPA_CONFIGFILE=/etc/wpa_supplicant.conf dhclient-wifi () { sudo dhclient $WIFI_IF } alias dw=dhclient-wifi scan-ssids () { sudo iw $WIFI_IF scan | grep -i ssid | sort --unique | cut -d ' ' -f 2- } alias sid=scan-ssids store-ssid () { local ssid="$@" local passphrase="whereisthegear" local command="wpa_passphrase $ssid $passphrase >> $WPA_CONFIGFILE" su -c $command } wifi-connect () { [[ ! -f $WPA_CONFIGFILE ]] && sudo touch $WPA_CONFIGFILE sudo wpa_supplicant -i $WIFI_IF -c $WPA_CONFIGFILE } alias wup=wifi-connect