Persistent IRC

I’ve gotten some favorable comments on the way that I do IRC, so I wanted to just share the approach that I’ve been using for some years now.

Of all the IRC clients I’ve used, I always seem to prefer irssi. Not only is the interface very simple and predictable, but using it with the screen utility is simply baller. Screen allows you to detach from a running terminal session without disturbing what’s running and reconnect later. (You can even connect from multiple locations at once!) The power with irssi should be obvious — the IRC session runs indefinitely and you can come and go as you please, all while keeping that connection to the server (or servers).

The requirement for my approach here is that you have a server that is always connected. The idea is that the screen/irssi combo is running there, and you connect to it from your workstation.

I always set up a global hotkey on my computers to open up a terminal and reconnect to the session on the server. I use Openbox on linux and Alfred on the Mac to accomplish this. In Openbox, I just launch my terminal app with the execute command flag, usually -e, passing in the command to execute the magic script on the server (seen between the quotes on the “do script” line below). On Alfred, I bind a global hotkey to this simple bit of AppleScript:

tell application "Terminal"
    activate
    do script "ssh -t user@server /home/user/.bin/irssi_screen.sh"
end tell

A “trick” I employ here is a little shell script I found somewhere* that checks for an existing instance of screen/irssi, resumes it if one exists, and fires up a new one if not. This way, you can do the exact same action whether you’ve started the irssi session since boot or not. Here is that script, placed at ~/.bin/irssi_screen.sh on the server. Be sure and set that executable bit!

#!/bin/bash
# Start a new screen session with irssi or attach to an already running one.
if screen -list | grep "\.irssi" > /dev/null
then # running
    screen -x irssi
else # not running
    screen -S irssi -t irssi irssi
fi

You can also set up desktop notifications for mentions/PM’s! I just actually set it up on my Mac with Growl according to this article. I did it once under linux, too.

If anybody out there finds this post helpful or has questions or comments, I would appreciate a comment! It’s quiet around here. :)

* Sorry I can’t give credit on this one; it was some time ago that I set this up. Edit: Actually, I just googled the comment and found about the only place it could have come from, this article on gregoa’s blog. Some other tips there, too.

Friday, August 5th, 2011 Computers, Software

1 Comment to Persistent IRC

  1. Irssi is the best bouncer.

  2. Jinx_player on August 6th, 2011

Leave a comment

Latest Tweets

Categories

My History