Reloading config from inside tmux

shell script

tmux’s prefix key

The default tmux prefix key is Ctrl-b, for the remainder of this article, we will refer to the prefix key as prefix.

The convention prefix,key means pressing prefix and the key after the prefix is released.

How tmux configurations are loadedLink to section

When tmux first starts, it will check for a file called $HOME/.tmux.conf. Sometimes you may see people refer to it as ~/.tmux.conf (same thing), or “.tmux.conf

You can kill all tmux sessions with the command $ killall tmux.

You can kill your current session from inside tmux with $ tmux kill-sess. If it’s your last session, it will stop the tmux server.

Then you can use the $ tmux command again to start a new tmux instance.

However, there is an easier way to reload tmux configurations.

Test settings outside of the configuration fileLink to section

While inside a tmux session, you can set keybindings via $ tmux bind-key and it will set to your current tmux’s config.

You can also set options with $ tmux set-option and $ tmux set-window-option.

This is valuable for experimenting with bindings and settings. However these settings will not carry over to other tmux instances. To do that, you must save any bindings or options inside the tmux config.

Manually reloading a configLink to section

prefix,: will replace the status bar at the bottom tmux with a prompt where you can enter text. From the prompt, this command reloads .tmux.conf in the home directory:

source ~/.tmux.conf

And hit Enter. This manually reruns the configuration file in the current tmux instance.

You can use the above command with any tmux file. For instance source path/to/my/file.conf.

Reloading via a shortcutLink to section

Inside your ~/.tmux.conf file, this binds leader+r to reload the configuration and display a message “Config reloaded…”:

Terminal window
# reload config
bind r source-file ~/.tmux.conf \; display-message "Config reloaded..."

Learn more about tmuxLink to section

For more tmux tips, check out The Tao of tmux: and Terminal Tricks available to read for free online, and on Amazon Kindle.