Daniel Keast

My current tmux config

programming

My configuration file for tmux has changed a lot over the years. I ended up with all sorts of custom settings after reading tmux by Brian P. Hogan, and the Arch Wiki page. Both are great resources, but I ended up with a config file that I didn’t fully understand or use. I’ve since trimmed it down to only the parts I use regularly. This should also make upgrades easier, since tmux has a habit of breaking config file compatibility between versions.

For starters, the vim motion keys feel more natural to me than the arrow keys for selecting panes. The arrow keys are far enough away that I may as well be using the mouse.

bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

I also set copy mode to use the vi keys:

set-window-option -g mode-keys vi

This means that once you’ve entered copy mode with <prefix> [, you can then move around and copy roughly as you would in vi. Version 2.4 altered the key bindings to make them closer to vi, but I’m currently using version 2.3 from Debian Stretch which uses these:

?
Search up
/
Search down
<space>
Enter visual selection
v
Toggle between line/block visual selection
<enter>
Copy selected area
gg
Go to top of history
G
Go to bottom of history
{
Go back a paragraph
}
Go forward a paragraph

I also enable mouse support. I try to not really use the mouse much, but I find it’s the simplest way to make small adjustments to the size of panes.

set -g mouse on

The most common resizing I do is just to set a pane to 80 characters wide, or sometimes to set the height to some small value. Other than that I toggle the pane to use the fullscreen:

<prefix> :resi<tab> -x 80
Make the current pane 80 characters wide
<prefix> :resi<tab> -y 10
Make the current pane 10 lines tall
<prefix> z
Toggle the current pane fullscreen

I disable the status line by default because I find it’s bright green background very distracting. I’ve gone through lots of different colour schemes for tmux to try and minimise the effect, as well as lots of different customisations for the content of the status line, but in the end I just don’t find it all that useful (you can list the current open windows with the <prefix> w command).

set -g status off

I use GNOME Terminal, which is generally absolutely fine but doesn’t support the escape code mechanism used by default to integrate with the system clipboard. When copying with this enabled you get some random characters on the screen and sometimes a system beep. Instead I set the y key to send the selection into xclip, which places it into the system clipboard.

set-option -s set-clipboard off
bind -t vi-copy y copy-pipe 'xclip -in -selection clipboard'

There is a common argument about tmux that the default prefix is difficult to press, and that <ctrl>-a is a significant improvement. I tried this for a while, but found myself using a claw-handed chord to type it, whereas the default forces me to use the proper touch-typing approach of right index finger on b, left little finger on left ctrl. I think this puts less stress on my wrists and forearms.

Another common recommendation is increasing the pane scrollback. It’s occasionally useful when a lot of text has flown past the screen to be able to scroll all the way up and copy a part of it. The problem with this is that a large scrollback can use a surprising amount of memory when you use lots windows and panes. This means that your operating system has less available for caches and disk buffers. Instead, I just use the standard Unix tools (file redirection/less/tee etc) the same as I do outside of tmux.

Here’s a raw copy of the whole config file.