Skip to content

Commit

Permalink
Add support for tab-arguments in new_tab action
Browse files Browse the repository at this point in the history
With the new_tab action accepting an argument it is now possible to
create key bindings which create tabs with particular command running.
  • Loading branch information
mina86 committed Jul 22, 2018
1 parent f9c55fa commit 6ca6f80
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions tabbedex
Expand Up @@ -320,9 +320,17 @@ Supported actions are:
=over
=item B<tabbedex:new_tab>
=item B<tabbedex:new_tab> or B<tabbedex:new_tab:I<arguments>>
Creates a new tab.
Creates a new tab. In the second form, I<arguments> temporarily override value
of the B<tab-arguments> resource. This makes it possible to create bindings
which start particular commands, for example:
URxvt.keysym.F1: tabbedex:new_tab:-e info
makes it such that pressing F1 will open a new tab running B<info> command.
(Remember that I<arguments> are passed as arguments to urxvt so to run a command
B<-e> is required as in example above).
=item B<tabbedex:next_tab> and B<tabbedex:prev_tab>
Expand Down Expand Up @@ -734,9 +742,11 @@ sub args_percent_substitution {
}

sub new_tab {
my ($root, $tab) = @_;
my ($root, $tab, $args) = @_;

my $args = $root->{tab_arguments};
if (!defined $args) {
$args = $root->{tab_arguments};
}
$args =~ s/^\s+|\s+$//g;
if ($args eq '' || $args eq '%e') {
$args = $root->{argv};
Expand Down Expand Up @@ -1125,9 +1135,9 @@ sub tab_add_lines {

sub tab_action {
my ($root, $tab, $cmd) = @_;
if ($cmd eq 'new_tab') {
if ($cmd =~ /^new_tab(?::(.*))?$/) {
if (!$root->{cur}->is_being_renamed) {
$root->new_tab($tab);
$root->new_tab($tab, $1);
}
} elsif ($cmd eq 'next_tab') {
$root->change_tab($tab, 1);
Expand Down

0 comments on commit 6ca6f80

Please sign in to comment.