tmux select-pane -LDUR command - disable auto-cycling behavior

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.

Source: github Issues thread that I started


Thanks to Gilgamesh Skytrooper for posting the issue on github. Here's a simple version that can work with multiple sessions and doesn't invoke a shell subprocess.

bind -n M-a if -F '#{pane_at_left}'   '' 'select-pane -L'
bind -n M-d if -F '#{pane_at_right}'  '' 'select-pane -R'
bind -n M-w if -F '#{pane_at_top}'    '' 'select-pane -U'
bind -n M-s if -F '#{pane_at_bottom}' '' 'select-pane -D'

Remove -n if you want to hit the prefix (C-b) first, and change the bindings M-[awds] to your liking.