Search code examples
macosgrowlgrowlnotify

How do I get growlnotify to show a multiple-line message from the command line?


Using growlnotify how can I display multiple lines of text from the command line?

Slash-n - \n - like this doesn't seem to work:

growlnotify -t title -m "messageline1\nmessage2"

I just get a message messageline1\nmessage2


Solution

  • The intended escaped newline is not interpreted as such by growl - it's just treated as a literal slash, followed by an 'en'.

    You can get the shell to insert a newline in the string this way:

    growlnotify -t title -m "messageline1"$'\n'"message2"
    

    See (e.g.) Unix command sh:

    Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specifed by the ANSI C standard.