This sounds good, except for this:
> osascript -e 'tell app id "com.Growl.GrowlHelperApp" to close all notifications'
that might close other notifications before you see them, or it might clear other 'sticky' notifications that you wanted to see.
There's a better way to do this, unfortunately it's not at all clear what this feature does until someone explains it.
First I'l quote the rather obscure text from `man growlnotify`:
> -d, --identifier = Sets the identifier for the notification. The identifier is used for coalescing, which means multiple notifications with the same identifer will use a single bubble, the latest notification taking precedence.
Ok, what does that mean? It means that you can assign a specific 'name' to a notification from `growlnotify` which won't show up anywhere in the notification itself, but you can use it again to replace that same notification.
I can hear you asking already: "Huh?"
Yeah, I know, it's better to have an example. So here's one:
#!/bin/zsh -f
NAME="$0:t:r"
growlnotify --identifier ThisIsSomeUniqueName --appIcon Terminal --sticky --message "Updating index of Hard Drive" --title "$NAME"
sudo find / -type f -print > "$HOME/Library/Logs/hd-index.txt"
growlnotify --identifier ThisIsSomeUniqueName --appIcon Terminal --message "Hard Drive Index updated" --title "$NAME"
exit 0
Note the lack of a '--sticky' in the second `growlnotify` line? Note that I used the same `--identifier` for both? The second one says "Replace the previous Growl notification with the same identifier (if it is still shown on the screen)."
Since the replacement is _not_ sticky, the notification will go away once the default time has passed.
You could also test the exit of the command and run a different notification depending on the outcome:
#!/bin/zsh -f
NAME="$0:t:r"
growlnotify --identifier ThisIsSomeUniqueName --appIcon Terminal --sticky --message "Updating index of Hard Drive" --title "$NAME"
sudo find / -type f -print > "$HOME/Library/Logs/hd-index.txt"
EXIT="$?"
if [ "$EXIT" = "0" ]
then
growlnotify --identifier ThisIsSomeUniqueName --appIcon Terminal --message "Hard Drive update succeeded" --title "$NAME"
exit 0
else
growlnotify --identifier ThisIsSomeUniqueName --appIcon Terminal --sticky --message "Hard Drive Index update FAILED (exit = $EXIT)" --title "$NAME"
exit 1
fi
exit
(Aside: if you read `man growlnotify` and see the `--wait` option, don't get excited: it doesn't work, it hasn't worked, and I'm starting to wonder if it will ever work.)
Second: I wrote a `growlnotify` wrapper https://github.com/tjluoma/...
It will:
* launch Growl.app if it's not running (basically so you don't have to autolaunch it on login, or if it crashes)
*re-launch Growl if `growlnotify` exits uncleanly (which usually means that Growl is hung up for some reason) *and* re-sends the Growl notification after Growl restarts.
*Maybe some other stuff I've forgotten :-)