Skip to content

Instantly share code, notes, and snippets.

@dyoder
Created December 6, 2012 00:59
Show Gist options
  • Save dyoder/4220996 to your computer and use it in GitHub Desktop.
Save dyoder/4220996 to your computer and use it in GitHub Desktop.
Using terminal-notifier with irssi and SSH

These are adapted from Ben Browning's blog post for using irssi with growl. I just wanted to use the Apple Notification center or whatever it's called. Fortunately, there's a nice gem that allows you to trigger Apple notifications from the command line. The only trick was that NSApplication has a screwy way of parsing command-line arguments and so the terminal-notifier command was failing. I fixed this with a stupid hack of putting an asterisk in front of the message.

I figured I'd post this in case someone runs into the same problem.

#!/bin/sh
# $argv = %r %h
# Kill all current fnotify sessions
ps | awk '{if($0 ~ /fnotify/ && $1 ~ /[0-9]+/ && $4 !~ /awk/) print $1}' |
while read id; do
kill $id
done
# SSH to host, clear file and listen for notifications
(ssh -i .ssh/personal.pem -q $1@$2 -o PermitLocalCommand=no "> .irssi/fnotify; tail -f .irssi/fnotify" |
while read heading message; do
# note the leading * below, which prevents the < being interpreted prematurely as the end of the parameter
terminal-notifier -title "${heading}" -message "* ${message}";
done)&
Host personal
Hostname <your-irssi-host>
User <your-username>
PermitLocalCommand yes
LocalCommand <path-to-your-irc-notify-shell-script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment