Command finished notification with Ruby

I wanted a visual notification in Ubuntu when long running commands finished in Terminal. My solution, run the command and pipe it into notify.

$ a-long-running-command | notify

notify.rb

#!/usr/bin/env ruby
require 'rubygems'
require 'libnotify'
Libnotify.show :summary => "Command finished.", :body => "#{ARGF.read}"

Make it executable

chmod u+x ~/scripts/notify.rb

add an alias to it in ~/.bashrc

alias notify="~/scripts/notify.rb"

Requires:
ruby
, rubygems, and libnotify.

Similar solutions:
“alert” alias (I’ll be switching to this in Maverick),
a python version

This entry was posted in code, ruby, ubuntu. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>