Skip to content

Instantly share code, notes, and snippets.

@marshall007
Created August 21, 2013 18:01
Show Gist options
  • Select an option

  • Save marshall007/6297796 to your computer and use it in GitHub Desktop.

Select an option

Save marshall007/6297796 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Usage:
# airport off
# airport on
# airport reset
# get current wifi device
CURRENT_DEVICE=$(networksetup -listallhardwareports | awk '$3=="Wi-Fi" {getline; print $2}')
echo "Current Wi-Fi Device: '$CURRENT_DEVICE'"
# turn wifi on/off
function power {
networksetup -setairportpower $CURRENT_DEVICE $1
}
if [ $1 == "reset" ]
then
power "off"
sleep 2
power "on"
else
power $1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment