Saturday, July 9, 2016

Nested Tmux Sessions

I use Tmux on my local machine and also prefer to use it once I'm logged in to remote machines. This posed a problem as commands intended for the remote Tmux were intercepted by the local Tmux.

A solution was found here: http://www.stahlke.org/dan/tmux-nested/

I'm not going to be repeating good advice again so here's my tmux.conf with the necessary changes.

set -g status-bg colour40
setw -g window-status-current-bg colour40

bind -n C-t new-window -a
bind -n S-left  prev
bind -n S-right next
bind -n S-C-left  swap-window -t -1
bind -n S-C-right swap-window -t +1

bind -n M-F11 set -qg status-bg colour25
bind -n M-F12 set -qg status-bg colour40
bind -n S-up \
 send-keys M-F12 \; \
 set -qg status-bg colour25 \; \
 unbind -n S-left \; \
 unbind -n S-right \; \
 unbind -n S-C-left \; \
 unbind -n S-C-right \; \
 unbind -n C-t \; \
 set -qg prefix C-a
bind -n S-down \
 send-keys M-F11 \; \
 set -qg status-bg colour40 \; \
 bind -n S-left  prev \; \
 bind -n S-right next \; \
 bind -n S-C-left swap-window -t -1 \; \
 bind -n S-C-right swap-window -t +1 \; \
 bind -n C-t new-window -a -c "#{pane_current_path}" \; \
 set -qg prefix C-b

Cheers!