X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=tmux-window.pl;h=0a27598e255c2fbda0347c145a52fcbd266cd378;hb=4eaab26cf84204122d3f5896412606f47b42aec7;hp=b16529b379fa52e1085a3692f205a0e58cae25c5;hpb=3f5d80c3a9142c424ca2c482b6ad28c475349d42;p=config%2Fdotfiles.git diff --git a/tmux-window.pl b/tmux-window.pl index b16529b..0a27598 100644 --- a/tmux-window.pl +++ b/tmux-window.pl @@ -6,7 +6,7 @@ # At the moment Tmux doesn't support mappings with multiple keys, e.g. prefix # ;0, prefix ;1 etc. (where ; is the common secondary prefix key). But this # works in GNU screen and is very useful to switch to windows quickly, e.g. -# prefix ;3 to switch to window 13 or ;;5 to switch to window 25. +# prefix ;3 to switch to window 13 or prefix ;;5 to switch to window 25. # # To simulate this missing feature ; and 0-9 must be rebound when prefix ; is # used, and unbound when ; or 0-9 was pressed and the window selected. This @@ -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. @@ -38,9 +41,9 @@ # bind-key \; source-file "/path/to/tmux-window1.conf" # # tmux-window1.conf automatically contains the path to tmux-window2.conf, -# therefore chaining for ;;3 will work to jump to window 33. +# therefore chaining for ;;3 will work to jump to window 23. -# Copyright (C) 2012 Simon Ruderich +# Copyright (C) 2012-2013 Simon Ruderich # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -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) {