you can use its tab bar. This is a nice and simple alternative to a multiplexor
like screen, or a tabbed terminal that uses a widget toolkit to create tabs
(such as konsole, xfterm4, and so on).
I didn't like the default appearance of URXVT's tab bar, so I decided to figure
out how to change it.
1. Colors
This is an easy one. You can add the following resources to your
$HOME/.Xdefaults file:
Code: Select all
URxvt.tabbed.tabbar-fg: 3
URxvt.tabbed.tabbar-bg: 0
URxvt.tabbed.tab-fg: 0
URxvt.tabbed.tab-bg: 1
set the color numbers to whatever you want, but hexadecimal values will not
work.
!!! NOTE: The changes below are SYSTEM-WIDE. !!!
2. The '[NEW]' button
This is not so easy. You'll have to edit the Perl file that is used to create
the tabs. First, make a backup copy:
Code: Select all
cp /usr/lib/urxvt/perl/tabbed $HOME/urxvt_perl_tabbed.original
chmod a-r $HOME/urxvt_perl_tabbed.original
cp $HOME/urxvt_perl_tabbed.original $HOME/urxvt_perl_tabbed
$EDITOR $HOME/urxvt_perl_tabbed
be opened for editing. Scroll down to about line 13 and you should see
something like:
Code: Select all
substr $text, 0, 7, "[NEW] |";
@$rend[0 .. 5] = ($self->{rs_tab}) x 6;
push @ofs, [0, 6, sub { $_[0]->new_tab }];
my $ofs = 7;
my $idx = 0;
whatever you want, and note the number of characters. In my case, I chose
Code: Select all
substr $text, 0, 7, " + |";
the following non-zero integers in this section. In my example, my string was
3 characters less than the original, so, in order to line everything up, I have
to subtract 3 from those integers, and I end up with:
Code: Select all
substr $text, 0, 4, " + |";
@$rend[0 .. 2] = ($self->{rs_tab}) x 3;
push @ofs, [0, 3, sub { $_[0]->new_tab }];
my $ofs = 4;
my $idx = 0;
You can of course apply my patch in one fell swoop:
Code: Select all
cp /usr/lib/urxvt/perl/tabbed /usr/lib/urxvt/perl/tabbed.orig ; curl https://github.com/dbbolton/urxvt-stuff/raw/cc1e79668b8d18955ad8720295915f42b4086fc2/tabbed.patch | patch -p0
3. The tab names
This one isn't exactly a picnic either. Scroll down to around line 20, and you
should see this:
Code: Select all
for my $tab (@{ $self->{tabs} }) {
$idx++;
my $act = $tab->{activity} && $tab != $self->{cur}
? "*" : " ";
my $txt = "$act$idx$act";
my $len = length $txt;
is 1, the next 2, and so on.
This is where you have some options. If you simply put the post-incrememnt,
$txt++;, after the line where $txt is set, your tabs will start at 0 and go up.
If you wanted to be a bit more creative, you could make a simple hash to store
custom names for the tabs. Here is an example:
Code: Select all
my %tabnames = (
'1' => 'α',
'2' => 'β',
'3' => 'γ',
'4' => 'δ',
'5' => 'ε',
);
global variable to hold the current tab's name:
Code: Select all
my $tabtxt;
you planned:
Code: Select all
if ($tabnames{$idx}) {
$tabtxt = $tabnames{$idx};
}
else {
$tabtxt = $idx;
}
All in all, my changes look like this:
Code: Select all
substr $text, 0, 4, " + |";
@$rend[0 .. 2] = ($self->{rs_tab}) x 3;
push @ofs, [0, 3, sub { $_[0]->new_tab }];
my $ofs = 4;
my $idx = 0;
my %tabnames = (
'1' => 'α',
'2' => 'β',
'3' => 'γ',
'4' => 'δ',
'5' => 'ε',
);
my $tabtxt;
for my $tab (@{ $self->{tabs} }) {
$idx++;
my $act = $tab->{activity} && $tab != $self->{cur}
? "*" : " ";
if ($tabnames{$idx}) {
$tabtxt = $tabnames{$idx};
}
else {
$tabtxt = $idx;
}
my $txt = "$act$tabtxt$act";
my $len = length $txt;
Just move the edited file back to the default location (as root):
Code: Select all
# mv -i $HOME/urxvt_perl_tabbed /usr/lib/urxvt/perl/tabbed