88

I just installed tmux on Ubuntu 10.04 and tried to remap the prefix key to C-a by creating the file ~/.tmux.conf with these lines:

set-option -g prefix C-a
unbind-key C-b

When starting tmux, both regularly and with -f ~/.tmux.conf, the prefix is effectively the same default C-b

There are no errors or warnings whatsoever.

Any idea what's wrong with the loading of the conf?

  • It Works For Me™. Try running strace -s9999 -f -o tmux.strace tmux -c true and post the output of grep -C5 'tmux\.conf' tmux.strace. – Gilles 'SO- stop being evil' Sep 14 '10 at 20:24
  • I had this same problem, no existing sessions, ('tmux ls' reported connection refused, i.e. not running), but it still wasn't reading the conf file. I was launching it with a CWD somewhere in /usr, but when I switched to ~/ and launched tmux, it processed the conf file. It's weird behaviour, but that's something to check. – Ranko Kohime Jan 26 '13 at 21:30
119

The file ~/.tmux.conf is loaded when the tmux server is first started. So if there are existing tmux sessions, starting a new session with tmux does not result in reloading the .tmux.conf file. Try restarting tmux server: Use the command tmux list-sessions to see if there are existing sessions. Exit them (e.g. tmux attach then kill all windows and exit). Once all sessions are gone, try tmux again. This time the rebinding should work.

  • 27
    killall tmux or tmux kill-server will get the job done too – Matt Jun 25 '11 at 2:01
  • 5
    I used killall tmux and tmux kill-server and still my conf is not loaded. I can confirm it is valid, since using :source-file ~/.tmux.conf in tmux does actually make the config changes! Can't figure out what is causing this behavior. – Ambidex Apr 24 '15 at 8:17
  • I wonder why reloading the config wasn't mentioned in this answer. It sometimes works and sometimes doesn't. Any ideas on that? – DarthPaghius Apr 13 '18 at 0:25
54

To reload your ~/.tmux.conf without killing your session, you can simply do:

C-b :source-file /absolute/path/to/your/.tmux.conf
  • 4
    You can add the following to .tmux.conf to use Ctrl-A r to reload: bind r source-file ~/.tmux.conf \; display-message "Config reloaded..." – RedPixel Aug 19 '15 at 8:08
  • +1 for pointing out the necessity of absolute path – Akash Agarwal Jan 28 at 22:43
20

run inside your tmux session:

tmux source-file /absolute/path/to/your/.tmux.conf
  • Note: this will not affect the current tmux window (obviously), but all new tmux windows. – Klaws Mar 12 at 7:21
3

There's also a default keyboard shortcut binding to reload your ~/.tmux.conf, at least in my installation: C-b r. If you hit C-b ? it brings up a list of all bound keyboard shortcuts, so you can see if you have one already defined.

  • That is specific to your installation/configuration. By default, <prefix> r is bound to refresh-client (what you describe would be something like source ~/.tmux.conf). – Chris Johnsen Jan 1 '12 at 3:09
1

I had this problem because I was using tmux-next.

Initially I solved it just by passing the config file explicitly tmux -f ~/.tmux.conf as the question here points out. (I had already aliased tmux-next to tmux.)

Then I realised tmux-next is using tmux-next.conf, so just symlink it if using this and only need to run the next tmux version.

ln -s ~/.tmux.conf ~/.tmux-next.conf

1

I quit and reopened my terminal and that's the only way I could get it to work again. Not sure why.

using Terminal on Mac OSX

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.