You can do this manually by modifying the perl extension for tabs (tabbed) and changing the keys it responds to. I got it to change tabs with alt + 1 ... alt + 9 by modifying the tab_key_press method:
You can get the original tabbed script from the source distribution of urxvt in the folder rxvt-unicode-9.15/src/perl/tabbed, find the function, and replace it with the method below.
When that is done, you can save the modified file in /some/folder/tabz and
run urxvt with urxvt --perl-lib /some/folder -pe tabz
I think it should be possible to configure this with with X resources (~/.Xdefaults), so perhaps I'll make a version of the script that reads from there in the future and mail it to the urxvt maintainer, but for now:
sub tab_key_press {
my ($self, $tab, $event, $keysym, $str) = @_;
warn "keysym: ", $keysym;
#if ($event->{state} & urxvt::ShiftMask) {
if ($event->{state} & urxvt::Mod1Mask) {
if ($keysym == 0xff51 || $keysym == 0xff53) {
my ($idx) = grep $self->{tabs}[$_] == $tab, 0 .. $#{ $self->{tabs} };
--$idx if $keysym == 0xff51;
++$idx if $keysym == 0xff53;
$self->make_current ($self->{tabs}[$idx % @{ $self->{tabs}}]);
return 1;
} elsif ($keysym == 0xff54) {
$self->new_tab;
return 1;
} elsif ( $keysym == 0x31 || $keysym == 0x32 || $keysym == 0x33 ||
$keysym == 0x34 || $keysym == 0x35 || $keysym == 0x36 ||
$keysym == 0x37 || $keysym == 0x38 || $keysym == 0x39
) {
my $idx = 0;
$idx = 0 if $keysym == 0x31;
$idx = 1 if $keysym == 0x32;
$idx = 2 if $keysym == 0x33;
$idx = 3 if $keysym == 0x34;
$idx = 4 if $keysym == 0x35;
$idx = 5 if $keysym == 0x36;
$idx = 6 if $keysym == 0x37;
$idx = 7 if $keysym == 0x38;
$idx = 8 if $keysym == 0x39;
warn scalar @{ $self->{tabs} };
$self->make_current ($self->{tabs}[ $idx ]) if ($idx < (scalar @{$self->{tabs}})) ;
return 1;
}
}
elsif ($event->{state} & urxvt::ControlMask) {
if ($keysym == 0xff51 || $keysym == 0xff53) {
my ($idx1) = grep $self->{tabs}[$_] == $tab, 0 .. $#{ $self->{tabs} };
my $idx2 = ($idx1 + ($keysym == 0xff51 ? -1 : +1)) % @{ $self->{tabs} };
($self->{tabs}[$idx1], $self->{tabs}[$idx2]) =
($self->{tabs}[$idx2], $self->{tabs}[$idx1]);
$self->make_current ($self->{tabs}[$idx2]);
return 1;
}
}
()
}
cross posted: http://unix.stackexchange.com/questions/40235/porting-gnome-keyboard-shortcuts-to-urxvt
– slm – 2014-05-10T01:43:03.503