I would like to manage my Mac's Wi-Fi on the command line, but there are lots of different built-in Mac utilities that need to be called (airport, ipconfig, networksetup, netstat, security), with various options. I'd like a simple way to do the most common operations. Is there anything like that out there?


I just released a command line utility, mac-wifi, hosted at https://github.com/keithrbennett/macwifi, which meets these needs (at least for me, at this time, feel free to offer suggestions). It is a Ruby script, and can be installed in either of these ways:

  • gem install mac-wifi
  • curl https://raw.githubusercontent.com/keithrbennett/macwifi/master/bin/mac-wifi -o mac-wifi && chmod +x mac-wifi

For interactive use (it has a shell to keep it open to more simply type multiple commands) you will need to install the pry gem:

gem install pry

Here is its help output:

mac-wifi version 1.1.0 -- Available commands are:

ci                      - connected to Internet (not just wifi on)?
co[nnect] network-name  - turns wifi on, connects to network-name
cy[cle]                 - turns wifi off, then on, preserving network selection
d[isconnect]            - disconnects from current network, does not turn off wifi
h[elp]                  - prints this help
i[nfo]                  - prints wifi-related information
lsp[referred]           - lists preferred (not necessarily available) networks
lsa[vailable]           - lists available networks
n[etwork_name]          - name (SSID) of currently connected network
on                      - turns wifi on
of[f]                   - turns wifi off
pa[ssword] network-name - shows password for preferred network-name
q[uit]                  - exits this program (interactive shell mode only)
r[m] network-name       - removes network-name from the preferred networks list
s[hell]                 - opens an interactive pry shell (command line only)
t[ill]                  - returns when the desired Internet connection state is true. Options:
                          'on'/:on or 'off'/:off
                          wait interval, in seconds (optional, defaults to 0.5 seconds)
w[ifion]                - is the wifi on?
x[it]                   - exits this program (interactive shell mode only)

When in interactive shell mode:
    * use quotes for string parameters such as method names.
    * for pry commands, use prefix `%`.
  • This script has been updated; I have just updated the help output above to version 1.1.0, but to be sure you are looking at the current version, please look at github.com/keithrbennett/macwifi. – Keith Bennett Oct 5 '17 at 4:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .