Keep the customer notified

Here’s a handy utility for those using Mountain Lion’s new Notifications system (something I find I rather like despite never really getting on with Growl).

It’s called ‘terminal-notifier’ by Eloy DurĂ¡n, and it lets you send these from the command line. So, for example:

   $ terminal-notifier \
     -message “Shall I compare thee to a summer’s day?” \
     -title “Morning greeting” -execute “open http://bbc.co.uk/weather/2653941”

This pops up a little notification, and clicking on it will take you to the BBC weather forecast for Cambridge.

You could put the command all on one line – I’ve just split it up with backslashes for readability. It’s easy to install terminal-notifier from the command line with:

  $ sudo gem install terminal-notifier

Now, as an illustration of why it can be useful, I wanted this for a particular purpose:

I’ve been experimenting more and more with Multimarkdown, since so much of what I write ends up in HTML, and the markdown syntax is a convenient way to create it. I have an Automator service which takes the currently selected text, for example in a blog post text-entry field, parses it as Markdown, and replaces it with the HTML equivalent. I’ve assigned it a keystroke, so typically I’ll just do Cmd-A to select everything I’ve typed and Ctrl-Alt-Cmd-M to convert it to nice HTML. Very handy. It’s how I wrote this.

Just occasionally, however, I might want to go back to the Markdown version, so before conversion the selected text is also copied into the clipboard. This is the kind of quick temporary backup that becomes second nature if you have a clipboard history utility. But it’s easy to forget this has happened.

Now, I can just add a quick extra line in the automator script and I get a little pop-up to remind me, which vanishes again after a few seconds:

Thanks, Eloy!

Here’s what the Automator service looks like, in case anyone wants to do something similar:

Got Something To Say:

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

*

© Copyright Quentin Stafford-Fraser