MNU 1.3.0 is out now — and it’s more Shell friendly than ever

I have just released version 1.3.0 of MNU, my macOS menu bar utility. Usually I’d just post a very brief notification of the the update, but this release requires a little more explanation.

MNU: click’n’connect

For those who don’t know MNU, it adds a customisable menu of useful tools to the Mac menu bar. There are a number of built in controls to get you started — switch between macOS’ light and dark mode; show or hide dot (‘hidden’) files in Finder; show or hide files on the Desktop; and update and upgrade a Homebrew installation — and you can add your own.

You might use MNU to open a favourite app as an alternative to the Dock. However, it was written to allow you to run frequently used shell scripts in macOS’ Terminal with just a couple of clicks: one to open MNU, the other to select the command you want to run.

Enter your own Shell commands, ready for quick selection from MNU

I have a stack of scripts I call regularly — backing up media folders, for example, and updating configuration files across multiple Macs — and I trigger all these from MNU. It saves a lot of typing.

Previous versions of MNU required the calls that trigger scripts — which can be run in Terminal or independent of it — to be fairly simple: in practice, that meant MNU didn’t support Shell quoting, the process of marking sections of a command for being interpreted as a unit rather than as separate words. For example, the line

cp $HOME/my big folder/ $HOME/folder-back-up

will fail because the spaces in the first path mean that it gets treated as three separate arguments — cp only takes two — or even more if the value of the variable $HOME also contains spaces. The fix is to quote those sections of the command:

cp "$HOME/my big folder/" "$HOME/folder-back-up"

Adding double-quote marks this way causes the Shell to treat the text within the quotes as a single unit rather than three space-separated units.

MNU didn’t allow this — the double quote marks confused it and this caused quoted commands to silently fail.

No longer. With release 1.3.0, MNU supports quoting, so you can use commands like:

echo "The value of \$HOME is $HOME"
echo "You have `ls | wc -l` files in `pwd`"
echo '"$GIT"'

and they will work as they should:

$ The value of $HOME is /Users/smitty
$ You have       19 files in /Users/smitty
$ "$GIT"

As you can see from the first of the examples listed above, you can also include escapes in quoted text, to include symbols which would otherwise be given special treatment by the Shell.

Pick an icon…

If, like me, you use the Z Shell, you don’t need to quote variables — when their values are substituted in, Z automatically quotes them (by default; you can turn this off if you prefer). But other command sections may well require quoting, and this important feature now means the MNU is good to go with those too, making it a lot more useful.

MNU 1.3.0 can be downloaded from my software site, where you’ll also find full usage instructions. Check it out — there’s a built-in feedback system (on the About MNU… tab) so please submit any bugs you find.