tmux: basic configuration
I’m a tmux user for most of my console sessions these days – both at work and at home. Spending some time configuring and fine-tuning tmux will go a long way as you can make this already powerful tool into a truly indispensable one.
This is the first of a few posts around tmux configuration: I would like to gradually introduce useful settings rather than just share the tmux config file. All the changes are made in the .tmux.conf file in your home directory.
Change tmux meta key
This is the very first thing I do on most tmux setups of mine: remap the Ctrl+B meta key to something easier to use.
Since I’ve been mostly on the MacOS platform for the past 5 years, I really like doing two things on the UK keyboard I have:
- map the tilda button (top left, just unde the Escape key) to backtick (`)
- map backtick (`) as the new tmux meta-key
These two steps truly change that key to a modifier key, making it much easier to invoke tmux keyboard shortcuts.
Here are the configuration lines for this:
# change default key to back-tick set -g prefix ` bind-key ` send-prefix unbind C-b
Make tmux count windows from 1
Could be just me, but I really like my tmux windows to be numbered starting with 1 instead of the default 0. With the tmux meta key properly mapped, it just makes a lot more sense to use “meta key + 1” for selecting the first window, instead of using “meta key + 0” which is all the way across the top row of keys on the keyboard.
Here’s how I do this in .tmux.conf file:
# change pane numbers to start with 1 instead of 0 set -g base-index 1 set -g pane-base-index 1
End result should be this:
Bind a key to re-load tmux config
This is the last of the initial changes I’m making to any tmux configuration: I map a certain key (meta-key + r) to reload the tmux configuration file. This saves me a restart of tmux every time I tweak some setting.
Here’s the portion from my .tmux.conf:
# bind reload key bind-key r source-file ~/.tmux.conf \; display-message "Config reloaded!"
After you start tmux with these options in it, you can at any time press Meta-key + r and see that your .tmux.conf has just been reloaded and therefore activated: