Change Window Shortcuts in Irssi

I love Irssi in combination with screen. It is a beautiful thing. For those of you who don't use it, try it. You'll never go back.

Getting the hang of windows in Irssi can be somewhat tricky when first using it, because everything is command line. So, changing windows is done using the keyboard. Pressing 'Esc' then a number (0-9) will take you to that window (0 = 10), as will 'Alt (0-9)' and 'Ctrl+(N,P)'. But, if you are a power user, you probably have more than 10 windows open at any given time. How do you get to those windows? 'Ctrl N' will take you to the next window and 'Ctrl P' will take you to the previous, but they are all in succession. How do you jump from window 11 to window 15 for example. You could type '/window 15' to take you there and '/window 11' to get you back, but that is too much work.

Irssi is set up with QWERTY users in mind, as it should be. As such, if you are using the QWERTY layout, then 'Esc q' (or 'Alt q') will take you to window 11, 'Esc w' will take you to 12, 'Esc e' to 13 and so on for the entire top row of letters. That takes care of the first 20 windows. But, if you are a Dvorak user as I am, the top row of letters in QWERTY are scattered about the keys, and it doesn't make logical sense for which window shortcut is where. So, how to change this?

In step the '/alias' command in Irssi. Without going into detail, the '/alias' command gives you the ability to create your own aliases. With it, you can change keyboard bindings as you please. As such, we should be able to create an alias that will allow us to use the Dvorak layout when switching windows and another alias for QWERTY. In fact, that is exactly what we can do.

In the alias, we will need to delete the current key bindings, then assign the new ones to the appropriate keys. "bind -delete meta-q" will delete the assinment to the 'q' key, and "bind meta-' change_window 11" will change the key assignment to the tick (') to go to window 11. Seperate each bind with a semicolon and we're set. Check it out:

Now, when in Irssi, I just type '/dvorak' and I have the entire top row of my keyboard, using the Dvorak layout, devoted to changing windows 11 through 20, using either the 'Esc' or 'Alt' keys. Type '/qwerty', and it is set back to the QWERTY layout for those shortcuts.

Cool.

Posted by Aaron Toponce on Tuesday, June 20, 2006, at 8:27 am.Filed under OSS.Follow any responses to this post with its comments RSS feed.You can post a comment or trackback from your blog.For IM, Email or Microblogs, here is the Shortlink.