There is an automatic way of doing this is OSX[1]. You may also want to use terminal-notifier instead of growl[2]. My experience was that the bash prompt became too slow. However, results seem to vary.
Good thing about bash script is that it works when you compile on remote Linux machine. terminal-notifier works only if you development is completely on Mac.