Skip to content

Instantly share code, notes, and snippets.

@midwire
Created July 10, 2014 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save midwire/8ed5d0dd33c71bcccfbe to your computer and use it in GitHub Desktop.
Save midwire/8ed5d0dd33c71bcccfbe to your computer and use it in GitHub Desktop.
Notify after a long-running shell command
#!/usr/bin/env ruby
require "rubygems"
require "thor"
require 'terminal-notifier'
class NotifyAfter < Thor
desc "after ARGS",
"ARGS is the after and list of arguments to run, after which you will be notified."
method_option :verbose,
:type => :boolean,
:default => false,
:required => false,
:aliases => "-v"
def after(*args)
# puts ">>> args: [#{args.join(' ')}]"
binary = args.shift
cmdline = "#{binary} #{args.join(' ')}"
output = `#{cmdline}`
puts(output)
TerminalNotifier.notify("Finished", :title => "#{binary} command")
end
end
NotifyAfter.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment