Tmux Config file
~/.tmux.confis the user's tmux config file. Can also have a global one in the
- Can define new shortcuts
- Can set up default environments
Changing the config of a running session
- Reload config file using
Suggested Configuration Changes
setcommand sets a option (short for
set-option). Use the
-gflag to make it global for all tmux sessions.
set -g prefix C-a. Remap
PREFIXto an easier key.
Ctrl-ais easier to hit especially if you have remapped Caps Lock to Ctrl (and you have done that haven't you?). Unbind the existing prefix using
bind C-a send-prefixwill allow us to send
Ctrl-ato an application by pressing it twice.
- Tmux adds a small delay when sending commands. To make this more responsive use
set -sg escape-time 1.
- Having 0 based windows and pages isn't great considering the layout of the number keys on a keyboard. We can make the indexes start from 1 by adding
setw -g base-index 1and
setw -g pane-base-index 1to our
~/.tmux.conffile. Note that these commands use
setwwhich is short for
- Turn the mouse off using
setw -g mode-mouse off. It is better in the long run as the mouse will only slow you down.
Suggested Shortcut Changes
- Can create new
PREFIX <char>shortcuts using the
bind <char> <commands>format.
- For example to bind
ctrl-rto reload your
tmux.conffile you can use
bind r source-file ~/.tmux.conf
- Can add a display command to show in the status line that something was done e.g.
bind r source-file ~/.tmux.conf \; display "Reloaded!"
- Can use
-nprefix to create a binding that does not require the tmux
PREFIX. However this will disable that binding for any application that's running in a tmux session so be very careful with this.
bind C-a send-prefix- use this to be able to send
ctrl-ato an application by presssing
Pane and Window Movement Shortcuts
- To spliting panes easier we remap these to use the | and - keys to create the appropriate split
bind | split-window -hand
bind - split-window -v
To make navigation between windows more
VIM like we can remap the keys for moving between panes to
bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R
We can also bind
ctrl-l to navigate between windows. Add these lines to the
bind -r C-h select-window -t :- bind -r C-l select-window -t :+
Pane Resizing Shortcuts
- To resize a pane we can use the
resize-panecommand passing either
-Rto specify the direction.
- To make this easier use the following rebindings. The
-rflag makes the command repeatable so we can repeat the command by repeatedly pressing the key within 500 milliseconds.
bind -r H resize-pane -L 5 bind -r J resize-pane -D 5 bind -r K resize-pane -U 5 bind -r L resize-pane -R 5
- Make sure the correct color mode is set in Tmux.
set -g default-terminal "screen-256color"
- This still didn't work for me so I needed to pass the
-2argument to tmux when starting e.g.
tmux -2 attach
- From vim to verify that this is working I used the Xterm Color Table plugin.