Magic Launch 1.3: The power of shell commands

A new month, a new feature for Magic Launch. In this month’s episode, witness the incredible flexibility of mapping file type to shell commands (instead of mere applications). This proves the immense superiority of the Mac platform… Wait! Crap. Linux and Windows have that feature too, built-in, and since forever. Anyway, here’s how it works on a Mac with Magic Launch.

Settings for opening files in the command-line text editor Emacs.

I think the above picture summarizes well: you can write a command of your choice, a double-hash “##” in the command is replaced by the full path of the file, and you can choose between running it a terminal window, or run it faceless (useful to start X11 apps).

A few more details: the command is executed in your home directory using your default shell (bash if you haven’t changed anything), and the double-hash substitution works mostly like for $shell_variables:

  • If the double-hash is not quoted, it gets quoted if it contains spaces or other irregular characters.
  • If the double-hash is inside double quotes, special characters gets escaped as necessary (based on bash syntax).
  • If the double-hash is inside simple quotes, no substitution occurs.
  • Escaped hashes — those prefixed with a backslash — such as “#” cannot take part in a substitution.
Command As executed for “/a file.txt”
emacs ## emacs '/a file.txt'
emacs "##" emacs "/a file.txt"
emacs '##' emacs ##
emacs ## emacs ##

Version 1.3 also adds a new upgrade tweak. If you’re upgrading the Magic Launch by double-clicking the new file and having System Preference install it, you’ll see it quit and relaunch before opening the preference pane. Don’t panic, this is on purpose. This inconvenience is necessary for Magic Launch to work correctly when opening it the first time after the upgrade, all this thanks to a bug in System Preferences.


  • © 2003–2024 Michel Fortin.