Skip to content

Instantly share code, notes, and snippets.

@flpwgr
Last active August 29, 2015 13:56
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 flpwgr/9234553 to your computer and use it in GitHub Desktop.
Save flpwgr/9234553 to your computer and use it in GitHub Desktop.
# Author: Felipe Wagner
#
# Have a Mac?
# Do you spend all day in terminal?
# Well, then u are just like me.
#
# Just add this little script into your .bash_profile, and then type:
# wifi (on|off) .... and done, all your airport interfaces will turn on/off
#
# v3: wifi (on|off) [interface]
# v2: All airport/wifi interfaces disable at the same time
# v1: Initial version
#
function wifi(){
_interface=`networksetup -listallhardwareports | grep -E '(Wi-Fi|AirPort)' -A 1 | grep -o "en."`
_opt=$1
if test "x${_opt}" = "x" ; then
echo "$FUNCNAME (on|off)"
return 1
elif test "${_opt}" = "on" -o "${_opt}" = "off" ; then
for in in $_interface ; do
networksetup -setairportpower $in $_opt
done
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment