My problem is I can't make tmux
key bindings to switch windows.
I'm running tmux
terminal multiplexer on the FreeBSD server. tmux
is started automatically for all remote logins using ~/.bash_profile
:
if [ $TERM = "xterm" ]; then
( (tmux has-session -t remote && tmux attach-session -t remote) \
|| (tmux new-session -s remote) ) && exit 0
echo "tmux failed to start"
fi
By default, tmux
windows are switched using Ctrl+B 1, Ctrl+B 2 ...
I want to switch tmux
windows using F1, F2 ...
So I added the following lines to ~/.tmux.conf
:
bind-key -n F1 select-window -t :1
bind-key -n F2 select-window -t :2
bind-key -n F3 select-window -t :3
bind-key -n F4 select-window -t :4
bind-key -n F5 select-window -t :5
bind-key -n F6 select-window -t :6
bind-key -n F7 select-window -t :7
bind-key -n F8 select-window -t :8
bind-key -n F9 select-window -t :9
Now when I login and press F1, tmux
says: "Window not found: :1".
I've tried to change to bind-key -n F1 select-window -t remote:1
, the error message is similar: "Window not found: remote:1".
Switching windows from command line works, both tmux select-window -t :1
and tmux select-window -t remote:1
.
How can I make it work as a key binding?
Answer
Try checking for non-visible characters in your ~/.tmux.conf
file. I am able to reproduce your symptoms when the bind-key
lines end with a CR (i.e. DOS/Windows-style line endings).
If you use Vim to edit, check the fileformat
with :set ff?
. If it is set to dos
, then you can fix the file with this command:
:set ff=unix|w
If fileformat
was already set to unix
, then inspect the individual lines; if there are CR characters there, they should show up as ^M
.
No comments:
Post a Comment