Using iTerm2 with Growl for Notifications

When I compile or do any other operation in terminal that takes a long time, I usually switch to browser or start doing something else – who wants to stare at terminal doing nothing for 10 minutes. Before I started using Growl, I was constantly switching forth and back from terminal to check if program finished compiling. It was distracting and unreliable. Sometimes there was error in code and compiling failed in less than a minute, but I did not know about it until I checked terminal five minutes later.

To fix this I use Growl – well-known notification program for MacOS. You have to pay for Growl but benefits outweight small price you have to pay for it (alternatively source code is available and you can build it yourself for free). I use MacBook Air as desktop with almost all work done on Linux server – so script is for Linux.

What I did before

[sergeyma@dev1456 ~] make

What I do now

[sergeyma@dev1456 ~] make; growl "make finished"

When make finish working, I get a nice notification from Growl – I know that operation ended.

Setting it all up

Add growl function to your .bashrc file in Linux

# A bash function to display a growl notification using iTerm's magic
# escape sequence. This version will work under screen.

growl() {
      local msg="\\e]9;\n\n${*}\\007"
      case $TERM in
          echo -ne '\eP'${msg}'\e\\' ;;
          echo -ne ${msg} ;;

Enable iTerm2 integration in Growl

That’s it – I hope it will save you time!

This entry was posted in linux, mac, productivity. Bookmark the permalink.

Nice tip ! Thanks for sharing.
I also use something like this : Once you installed terminal-notifier, you can also bypass growl completely and use the notification center, having a function like

function growl() {
    terminal-notifier -activate com.googlecode.iterm2 -title "Pssssst !!" -subtitle "A message from your shell:" -message "$@"

which render your previous message just like this and bring the terminal (iTerm2 in my case) on front once you click on the notification.

Because popup notifications are numerous those days, I also added an audio notification in my growl function :

function groooowl() {
    terminal-notifier -activate com.googlecode.iterm2 -title "Pssssst !!" -subtitle "A message from your shell:" -message "$@"
    say "$@"