3

As title. I always do things on macOS, but now I have to learn some Virtual Machine and have installed Ubuntu 20.04. On macOS I put all dotfiles inside the folder ~/.config/. I did the same on Ubuntu, but it didn't work. Now I have to run

tmux source ~/.config/tmux/tmux.conf

everytime I enter a session, or I will not be able to use those keybindings. So where should I put this config file? My intuition told me that I would need to create a symlink to the default path, which I don't know, to make this work.

3 Answers 3

3

Despite the two answers with the traditional tmux config locations, tmux 3.1 and later does support ~/.config/tmux/tmux.conf, although it's not mentioned in the man page. See the release notes here. That's why it works for you on MacOS.

However, the Ubuntu 20.04 repo looks like it's only at 3.0.

If you can run 21.04 or later in your VM, it should have an appropriate tmux version, and ~/.config/tmux/tmux.conf should be automatically handled for you.

If you are stuck on Ubuntu 20.04 for LTS reasons, then you can fall back to the symlink option, or use the -f option as in this question.

3
  • 1
    Wow, I just checked the version info. on macOS and Ubuntu, and the results are 3.2a, 3.0a, respectively, exactly like you said!
    – Niing
    Jan 1, 2022 at 5:14
  • 1
    @Niing, I decided to open a pull request suggesting the addition of this path in the manual page, so that we don't have to look at the changelog or source code and it was accepted by one of the maintainers, probably it will be easier to find this information in the next releases of tmux.
    – dandev486
    Jan 6, 2022 at 10:12
  • Thanks @dandev486. That will definitely help educate more people on the availability of this feature. Jan 6, 2022 at 13:19
1

According to the tmux man page the default location for the config files in Ubuntu is /etc/tmux.conf and ~/.tmux.conf

By default, tmux loads the system configuration file from /etc/tmux.conf, if present, then looks for a user configuration file at ~/.tmux.conf.

1
  • OK, I'm stupid. My ln -s command contains ~ in it. I was thinking about why I did the same but it didn't work as your answer.
    – Niing
    Dec 31, 2021 at 16:36
0

By default, tmux loads the system configuration file from /etc/tmux.conf, if present, then looks for a user configuration file at ~/.tmux.conf.

More information can be found on the command man page.

This is actually the default behaviour until tmux 3.0, apparently, even though it is undocumented on the manual page, the aforementioned path was added, as can be seen, when comparing the source code for tmux 3.0 and 3.1.

=====

[EDIT] The information will now be available at the manual page of a later version, I've made the suggestion and it was accepted by one of the maintainers, it has been commited to the master branch.

7
  • OK, I'm stupid. My ln -s command contains ~ in it. I was thinking about why I did the same but it didn't work as your answer.
    – Niing
    Dec 31, 2021 at 16:36
  • Could you elaborate more on why I don't have to add a symlink to ~/.tmux.conf on macOS?
    – Niing
    Dec 31, 2021 at 16:38
  • I don't own a mac, to be a hundred percent sure, honestly! However, the ~/.tmux.conf file in all my linux machines is a regular file, not a symbolic link.
    – dandev486
    Dec 31, 2021 at 16:40
  • 1
    It is not a bad idea storing your configuration files in a central location, it makes it easier to backup them and to know where things are. It is just not the default, location for tmux and you have to either manually close this gap in order to organize your computer in your own way, or otherwise add the tmux source line in a initialization script such as bashrc, for instance.
    – dandev486
    Dec 31, 2021 at 16:45
  • 1
    Last but not least, the correct command line is tmux source-file, not tmux source (man page for tmux 3.1c)
    – dandev486
    Dec 31, 2021 at 16:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .