From: Simon Ruderich Date: Sun, 21 Oct 2012 21:25:33 +0000 (+0200) Subject: tmux-window.pl: Call select-window last in the binding. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=8246405a007bc1a4e9ba0454f0ebb0d97f616ec3;p=config%2Fdotfiles.git tmux-window.pl: Call select-window last in the binding. Otherwise non-existent windows prevent unmapping the temporary 0-9 ; keys. --- diff --git a/tmux-window.pl b/tmux-window.pl index b16529b..9f3971c 100644 --- a/tmux-window.pl +++ b/tmux-window.pl @@ -20,6 +20,9 @@ # unbind-key -n 9 \; \ # unbind-key -n \\; # this unmaps ; # +# Due to Tmux's handling of errors (they abort the rest of the mapping) the +# select-window command is actually executed as last part of the mapping. +# # If a secondary chaining (e.g. prefix ;;3) is requested, a second file like # the generated one must be loaded with ; to jump to windows 20-29. Therefore # the following line is added in this case. @@ -75,11 +78,14 @@ if (defined $path and $path !~ m{^/}) { for (my $i = 0; $i < 10; $i++) { - print "bind-key -n $i select-window -t :$level$i \\; "; + print "bind-key -n $i "; for (my $j = 0; $j < 10; $j++) { print "unbind-key -n $j \\; "; } - print "unbind-key -n \\\\;\n"; + print "unbind-key -n \\\\; \\; "; + # Do the select-window last. If the window doesn't exist the failing + # select-window command prevents unbinding the other keys. + print "select-window -t :$level$i\n"; } if (defined $path) {