tmux disregarding the configuration file

94

22

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?

GJ.

Posted 2010-09-14T12:22:35.393

Reputation: 8 151

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' – 2010-09-14T20:24:02.743

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 – 2013-01-26T21:30:56.630

Answers

127

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.

Michael

Posted 2010-09-14T12:22:35.393

Reputation: 1 271

6I 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 – 2015-04-24T08:17:28.373

I wonder why reloading the config wasn't mentioned in this answer. It sometimes works and sometimes doesn't. Any ideas on that? – DarthPaghius – 2018-04-13T00:25:43.727

28killall tmux or tmux kill-server will get the job done too – Matt – 2011-06-25T02:01:03.853

56

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

C-b :source-file /absolute/path/to/your/.tmux.conf

peroumal1

Posted 2010-09-14T12:22:35.393

Reputation: 660

4You 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 – 2015-08-19T08:08:39.330

+1 for pointing out the necessity of absolute path – Akash Agarwal – 2019-01-28T22:43:34.650

22

run inside your tmux session:

tmux source-file /absolute/path/to/your/.tmux.conf

HVNSweeting

Posted 2010-09-14T12:22:35.393

Reputation: 618

Note: this will not affect the current tmux window (obviously), but all new tmux windows. – Klaws – 2019-03-12T07:21:34.913

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.

Josh Earl

Posted 2010-09-14T12:22:35.393

Reputation: 275

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 – 2012-01-01T03:09:43.740

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

mahemoff

Posted 2010-09-14T12:22:35.393

Reputation: 803

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

Connor McCormick

Posted 2010-09-14T12:22:35.393

Reputation: 171