Notifications from iTerm with content images

As an addition to the last Native OSX notifications from iTerm with Triggers article there is also a solution to add content images to the notifications.

We use the parameter -contentImage of terminal-notifier to display the image. To make it easier we adjust the script of the last article and add the -contentImage parameter.


require 'rubygems'
require 'terminal-notifier'

message = ARGV[0] || "Task completed"
title = ARGV[1] || "iTerm"
contentImage = ARGV[2] || ""
activate = 'com.googlecode.iterm2'
sender = 'com.googlecode.iterm2'

TerminalNotifier.notify(message, :title => title, :contentImage => contentImage, :activate => activate, :sender => sender)

We now display the notification with the following command:

iterm-notify "Tests successful" "PHPUnit" "/path/to/check.png"

The result will look like this now:

Notification with image