Quick Links

You can do a lot with the macOS Terminal, but the commands tend to be obtuse. A free program called m-cli bills itself a Swiss Army Knife for macOS, and it makes a lot of these hidden commands a lot easier to learn and discover.

Terminal commands are rarely intuitive. For example, if you want to add a recent items folder to your dock, this is the command:

        defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = {"list-type" = 1; }; "tile-type" = "recents-tile";}' && \killall Dock
    

Stare at this long enough and you can kind of figure out what it all means, but it's hard to imagine many users discovering it on their own. With m-cli installed, however, the command is much easier:

        m dock addrecentitems
    

M-cli makes hundreds of similar functions easy to discover and execute. Here's how to set it up, and what else you can do.

Installing m-cli in macOS

Related: How to Install Homebrew on a Mac

We've shown you how to install packages using Homebrew, and that's the easiest way to install m-cli. Once you have Homebrew set up, open the Terminal (Applications > Utilities > Terminal), then run the following command:

        brew install m-cli
    

If you don't have Homebrew set up, head to the m-cli page on Github for alternative installation instructions. Homebrew is going to be easier for you, however, and will also help keep everything up-to-date easily. (Not to mention it has a bunch of other useful tools.)

How to Use m-cli

The number of functions m-cli offers can be intimidating, but it's ultimately quite simple. Most commands are just three words:

        m
    

, followed by a two word command. To get started, type

        m help
    

. This will give you a list of functions, which I also outline in the section below.

m-help

Each of these commands can trigger at least one functionality. To find them, type

        m subcommand help
    

. For example, here's me exploring what

        dock
    

can do:

m-dock

As you can see,

        dock
    

offers several tweaks. In the above example I turned magnification on and off.

To learn a bit more, here's a look at the

        bluetooth
    

command.

m-bluetooth

As you can see, I can quickly turn Bluetooth on and off, and check the current status.

Finally, here's the

        wifi
    

command:

m-wifi

As you can see, I can turn the Wi-Fi on and offer, but also recover passwords for any network or scan all networks that are nearby.

Everything m-cli Offers

As we've said, there are 30 commands, all of which offer at least one sub-command. Here's a quick outline of what all of these commands can do:

  •         battery
        
    : See current battery status.
  •         bluetooth
        
    : See current Bluetooth status, turn Bluetooth on and off.
  •         dir
        
    : View trees of folders, quickly delete empty folders.
  •         disk
        
    : See information about connected drives, format drives, repair permissions.
  •         dns
        
    : Flush your DNS cache.
  •         dock
        
    : Change your Dock's settings, or add a recent items folder.
  •         finder
        
    : Toggle hidden files, extensions, and the desktop.
  •         firewall
        
    : Disable or enable the macOS firewall.
  •         gatekeeper
        
    : Disable or enable Gatekeeper.
  •         group
        
    : View or change groups of users on your Mac.
  •         hostname
        
    : View or change your Mac's hostname
  •         info
        
    : See what version of macOS you're running.
  •         lock
        
    : Lock your Mac.
  •         network
        
    : See or change your current location.
  •         nosleep
        
    : Stop your Mac from going to sleep, for a set number of seconds or until a particular command finishes.
  •         ntp
        
    : Toggle whether your Mac syncs its clock with a time server.
  •         restart
        
    : Tell your Mac to restart.
  •         safeboot
        
    : Tell your Mac to restart in Safe Boot.
  •         screensaver
        
    : Start the current default screensaver.
  •         service
        
    : See and monitor all currently running services.
  •         shutdown
        
    : Tell your Mac to shut down.
  •         sleep
        
    : Tell your Mac to go to sleep.
  •         timezone
        
    : Change your Mac's timezone.
  •         trash
        
    : Empty your Mac's Trash folder.
  •         update
        
    : Update Mac App Store software without launching the App Store
  •         user
        
    : Manage users on your Mac.
  •         volume
        
    : Change the volume on your Mac.
  •         vpn
        
    : Manage VPN connections.
  •         wallpaper
        
    : Set your Mac's wallpaper.
  •         wifi
        
    : Turn Wi-Fi on and off, retrieve your current Wi-Fi password, or scan all nearby networks.

Most of these things were possible to do from the command line before, but m-cli makes them a lot easier to discover and execute. If you're a command line junkie, there's no reason not to install it. And while you're at it, check out these other command line tools for Mac users.