Aug 22, 2020 How to Toggle WiFi On and Off with a Keyboard Shortcut on Mac. Once you set one up, you can use a keyboard shortcut to turn on or off your WiFi on a Mac, easily. 30 keyboard shortcuts Mac users need to know This collection of keyboard shortcuts for macOS can help users get the most from their iMacs, MacBook Pro and MacBook laptops.
Some Macs have the WiFi port is not 'en1' as in the Barney-15E's script (ex: MacBook Pro Retina 15 with Yosemite).
So, the script will work for switch WiFi to ON only.
I think it's regular for new Apple laptops without Ethernet RJ45 port.
Nars vs mac foundation for oily skin.
To solve the problem it should be define which en* port is WiFi in the system.
I used the Terminal command:
$ networksetup -listallhardwareports
and find my WiFi as 'en0' :
$ networksetup -listallhardwareports
Hardware Port: Wi-Fi
Device: en0
Ethernet Address: 12:00:7h:cb:c7:11
So the Barney-15E's beautiful script changed to:
if [[ `networksetup -getairportpower en0` *On ]]
then
networksetup -setairportpower en0 off
if [[ `networksetup -getairportpower en0` *On ]]
then
networksetup -setairportpower en0 off
List Of Keyboard Shortcuts
else
Mac Keyboard
networksetup -setairportpower en0 on
Turn On Keyboard
fi