A simple TMUX configuration

Table of Contents

tmux-logo

Why use tmux?

Tmux is a terminal multiplexer that is extremely useful when doing any remote SSH work. For instance, what if you want to run an interactive job on a remote HPC, but don’t want to lose all your work if you accidentally lose internet connection? Tmux is the key. Run a new terminal session, do some work, detach from that session and reattach to pick up where you last left off.

The downside to tmux is that it isn’t the most user-friendly of terminal applications (even by terminal application standards, in my opinion). The default Tmux configuration is missing some key quality-of-life features like mouse scrolling, vim-like keybindings, and easy window navigation between a pane running vim and a pane running the command-line.

My simple .tmux.conf configuration

Below is my quick and simple tmux configuration. It includes some basic conveniences and some highly useful plugins without going completely overboard. May this serve as a good starting point for your own tmux.conf :)

Note: first create the tmux config file with touch ~/.tmux.conf if you haven’t done so already.

# Allow mouse scrolling
set -g mouse on

# Allow default copy and pasting behaviour
set -s set-clipboard external

# History size
set -g history-limit 10000

# Allow config relaoding with <C-b> r
bind r source-file ~/.tmux.conf

# set vi-mode
set-window-option -g mode-keys vi

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'christoomey/vim-tmux-navigator'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'

# Prefix highlight on status bar
set -g status-right '#{prefix_highlight} | %a %Y-%m-%d %H:%M'

# Initialize TPM
# always keep this line at the bottom of the config file
run '~/.tmux/plugins/tpm/tpm'

The Tmux Plugins Manager (tpm) requires some minimal setup by first running git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm. After some plugins have been added to the tmux config file as seen above, the new tmux settings should take effect immediately with starting a new session. You can find this in my GitHub dotfiles repo too.

Useful resources