Is it possible to use the mouse to navigate between different window panes which are split vertically or horizontally?
Tmux, change window pane by mouse click
tmux
Related Solutions
You can jump directly to a pane by typing pane's index while it is showed by display-panes
command.
From man tmux
:
display-panes [-t target-client]
(alias: displayp)
Display a visible indicator of each pane shown by target-client.
See the display-panes-time, display-panes-colour, and
display-panes-active-colour session options. While the indicator
is on screen, a pane may be selected with the ‘0’ to ‘9’ keys.
Or instead of typing command, you can use:
C-b q
C-b
send prefix keyq
display panes indexes
Add this to your ~/.tmux.conf
:
set-option -g default-shell /bin/bash
unbind Up
unbind Down
unbind Right
unbind Left
bind Up run-shell "if [ $(tmux display-message -p '#{pane_at_top}') -ne 1 ]; then tmux select-pane -U; fi"
bind Down run-shell "if [ $(tmux display-message -p '#{pane_at_bottom}') -ne 1 ] ; then tmux select-pane -D; fi"
bind Right run-shell "if [ $(tmux display-message -p '#{pane_at_right}') -ne 1 ]; then tmux select-pane -R; fi"
bind Left run-shell "if [ $(tmux display-message -p '#{pane_at_left}') -ne 1 ]; then tmux select-pane -L; fi"
Basically, this should run with tmux versions 2.6 + (after which they added the pane_at_top, pane_at_bottom, pane_at_left, pane_at_right environment variables. For tmux < v2.6, I'm not entirely sure how you could implement this.
Further more, if you want to launch a custom-shell, do it through set-option -g default-command fish
(or zsh or csh or whatever). As an alternative, if you want to use a non-bash shell as your tmux default shell, set it as such (set-option -g default-shell
) and then you can code out the logic above in the shell script of your choice. However, (as was in my case) using certain shells doesn't give you the convenience of one-liner if commands (or it might just be I don't know enough about certain shells, or maybe multiple lines do work in run-shell.
Best Answer
As of tmux 2.1, you can enable this by adding it to your
.tmux.conf
:set -g mouse on
See the
mouse-select-pane
option inman tmux
:You can enable this by adding it to your
.tmux.conf
:set -g mouse-select-pane on