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
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
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.
I find it easier and much more readable in scripts to use a little function and echo
's -e
option:
mynotify () {
for m in "$@"; do
local msg="$msg\n$m"
done
echo -e "$msg" | growlnotify -t "My Title"
}
mynotify "This is line 1" "Line 2" "The 3d line ends with an extra newline\n" "Line 4"