This is a command line client for interacting with wifi on MacOS.
sudo pip3 install macos-wifi-cli
$ wifi --help
usage: wifi [-h] [-d DEVICE] {on,off,scan,connect,info,pass} ...
MacOS CLI tool for managing wifi connections
positional arguments:
{on,off,scan,connect,info,pass}
commands
on Turn on wifi
off Turn off wifi
scan Scan for wifi networks
connect Connect to wifi network
info Fetch current wifi info
pass Retrieve stored wifi passphrase
optional arguments:
-h, --help show this help message and exit
-d DEVICE, --device DEVICE Device
wifi on
wifi off
wifi scan
wifi connect --network "mynetwork" --password "mypassword"
Help:
$ wifi connect --help
usage: wifi connect [-h] -n NETWORK -p PASSWORD
optional arguments:
-h, --help show this help message and exit
-n NETWORK, --network NETWORK
SSID name
-p PASSWORD, --password PASSWORD
Wifi passphrase
Tip:
Use command substitution to retrieve the password securely so it's not saved in plaintext in your shell history.
For example, using pass:
wifi connect -n "mynetwork" -p $(pass wifi/home)
wifi info
wifi pass --network 'mynetwork'