Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to bind Alt + <number> key to switch tabs in urxvt.

Any approaches?

share|improve this question
up vote 5 down vote accepted

The code is in /usr/lib/urxvt/perl/tabbed (on my system at least).

On line 312, the sub that control key presses starts (sub tab_key_press). It checks $event->{state} and a key mask; by default either combinations with urxvt::ShiftMask or urxvt::ControlMask.

/usr/lib/urxvt/ shows other possibilities, e.g. Mod1Mask which is most likely the Alt modifier.

By default, only shortcuts for walking left or right among tabs are defined. It reads current position ($idx), then increases/decreases it by one ($idx++/$idx--), then sets this value as the new tab index.

With this information, it is easy to modify to

  1. Use the Mod1Mask.
  2. Read the key number pressed.
  3. Set the tab index to the read number.

(with minimal coding experience, not even necessarily Perl; it's mostly copy+paste).

share|improve this answer

Urxvt is not, by itself, a tabbed terminal. You can use a perl extension to get tabs. It might have some options to change the key binding. see the FAQ on that.

share|improve this answer
Indeed, I use the "tabbed" extension. But the shortcuts are rather inconvenient. Any way to change them? – Determinant Apr 8 '12 at 10:12
@ymfoi Not sure, possibly by editing the source code. I use the window-manager method (xfcewm) so I haven't tried that. – Keith Apr 8 '12 at 10:17
I'm not familiar with perl, can you figure out how to modify that file? – Determinant Apr 8 '12 at 10:45
What @Daniel said. I'm not a perl-ista, either. – Keith Apr 8 '12 at 13:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.