Tmux is a terminal multiplexer which allows multiple terminals to be created within a single screen, as well as detaching the terminal and continuing to run it's tasks in the background (allowing you to reconnect later)
$ apt-get install tmux
Setting this allows you to use the mouse to navigate between different panes.
set -g mouse on
When using vim within tmux, there's an issue where the escape time setting in
tmux makes exiting insert mode in vim via the escape
key slow to respond. This
setting resolves that issue.
set -s escape-time 0
By default, tmux uses Ctrl+b
to issue commands.
Screen, another
terminal multiplexer, uses Ctrl+a
. I originally used screen, so Ctrl+a
feels
normal to me and this configuration changes that.
unbind C-b
set -g prefix C-a
bind C-a send-prefix
I like using -
for adding a vertical split, and |
for adding a horizontal
split, so these settings rebind the split keys to those.
unbind |
unbind %
unbind -
bind | split-window -h
bind - split-window -v
Allows jumping between panes with Ctrl+a $VI_KEY
unbind h
unbind j
unbind k
unbind l
bind -r h select-pane -L
bind -r j select-pane -D
bind -r k select-pane -U
bind -r l select-pane -R
When working in the terminal, it's nice to have a large pane on top (for running an editor) with a couple of smaller panes underneath (for various command line tools, building, running tests, etc)
This alias, added to the ~/.bashrc
file (or wherever is appropriate) will
setup panes in that style just by using the command t
.
alias t='tmux new-session \; split-window -v \; split-window -h \; resize-pane -D 8 \;'