113

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?

2
  • 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. 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. Jan 26 '13 at 21:30
153

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.

3
  • 33
    killall tmux or tmux kill-server will get the job done too
    – Matt
    Jun 25 '11 at 2:01
  • 6
    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?
    – Paghillect
    Apr 13 '18 at 0:25
65

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

<prefix> :source-file /absolute/path/to/your/.tmux.conf

where <prefix> is <C-b> by default.

3
  • 7
    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
    +1 for pointing out the necessity of absolute path Jan 28 '19 at 22:43
  • 1
    Note that this was not enough for my use case. I had added some styles to my .tmux.conf, then removed them and reloaded, but some of them were not overwritten just by sourcing the file without them. I had to actively kill the session, and then the next session I created had the correct styling.
    – Neil Traft
    Oct 20 at 2:42
26

run inside your tmux session:

tmux source-file /absolute/path/to/your/.tmux.conf
1
  • 1
    Note: this will not affect the current tmux window (obviously), but all new tmux windows.
    – Klaws
    Mar 12 '19 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.

1
  • 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). Jan 1 '12 at 3:09
2

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

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

0

tmux not load ~/.tmux.conf automatically , you must source manually,for first time you install tmux or every time that you change any thing in ~/.tmux.conf by:

tmux source-file ~/.tmux.conf
  • it's different to source in vim (vim source if open and by source %.. )
  • tmux it's portable , you can source .tmux.conf from any folder ^_^ easy

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.