Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

Any approaches?

share|improve this question
add comment

2 Answers

up vote 4 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/urxvt.pm 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
add comment

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
add comment

Your Answer

 
discard

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.