Rails script/server and terminal windows

Here’s a little hack for those of you that run Rails’ script/server on its own window or tab.

By inserting a couple of lines into the server script, you can have it change the title of the window or tab it’s running on, making it a lot easier to look for it when you have lots of windows open.

Server Tab

All you need is to change “script/server” so it looks like this:

#!/usr/bin/ruby
print 33]2;Rails Server07 # xterm window title
print 33]1;Rails Server07 # screen/iterm tab title

require File.dirname(__FILE__) + /../config/boot
require commands/server

print 33]1; 07 # screen/iterm tab title
print 33]2; 07 # xterm window title

The second set of prints will clear the title after the server terminates. You might want to adjust it to suit your needs.

Leave a Reply