5

According to the man page, if I run this command:

tmux source-file ~/.tmux.conf

tmux is going to execute the commands in ~/.tmux.conf. However if, for example, I add a key binding to tmux.conf, and later remove it, the key binding stays, even if I source the file (which is logical, since there's no actual command to execute for that binding).

So I'm wondering, before sourcing the config, if there a way to somehow clear tmux's internal state (all binding, settings, etc.) so that it starts with the default one?

  • 1
    Quit and restart tmux. – Kusalananda Jun 26 '17 at 10:20
  • Sorry for the question, but how do I quit tmux? If I detach all sessions I see it's still running. Do I need to kill the process or is there a clean way to quit it? – laurent Jun 26 '17 at 10:29
  • 1
    tmux will still be running if you detach (that's one of the points of tmux after all). It will exit if all commands (shell sessions usually) that it's managing exits. – Kusalananda Jun 26 '17 at 10:30
5

Changing the tmux configuration and rereading it in an existing tmux session will only change the settings that the configuration file explicitly changes. Removing a key binding from the configuration file, for example, will not unbind that key when you reload the configuration unless you also explicitly unbind it in the configuration.

This is similar to sourcing a shell script with a variable assignment in it; You source it once, which sets the variable, and then you remove it from the file and source it again. This will not remove the shell variable.

The simplest way to reread the configuration file from scratch is to exit tmux and restart it. tmux will exit as soon as all its sessions have ended, which will happen if you, for example, exit all shell sessions from within tmux. You may also issue the tmux command kill-server from within tmux to kill the tmux server and all sessions.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.