26

I want to move the .tmux.conf file from ~ to ./config/..., but I'm not sure about whether this would lead to tmux would not know about this location. So where are the alternative location(s) where tmux will source its .tmux.conf file?

2 Answers 2

34

Starting with tmux version 3.1, ~/.config/tmux/tmux.conf works as an alternative to ~/.tmux.conf. Notice that it cannot be a hidden file in that directory.

3
  • 5
    This answer is non-trivial because it seems ~/.config/tmux/tmux.conf is not mentioned in the documentation like man tmux (at least for now). It's in the changelog and in Makefile.am. tmux 3.2 checks $XDG_CONFIG_HOME/tmux/tmux.conf as well. Commented Apr 13, 2021 at 22:28
  • 2
    this is documented now: github.com/tmux/tmux/pull/3023 hopefully it'll start appearing in distro man-pages soon
    – Sam Mason
    Commented Feb 9, 2022 at 19:21
  • and the contents of ~/.tmux? Also into .config/tmux?
    – RichieHH
    Commented Dec 6, 2023 at 10:31
3

Niing's answer is a great solution, and I would recommend it as the self-accepted answer.

For anyone using a tmux release prior to 3.1, or who wants to use a location other than ~/.tmux.conf or ~/.config/tmux/tmux.conf, it is also possible to specify an arbitrary location for the configuration when starting with tmux -f <file_location> (e.g. tmux -f ~/.config/tmux.conf). You can, of course, wrap this in a shell function, an alias, or a shell script to make it quicker to type.

This works great for specifying alternative configurations that you may need only occasionally. For example, I have a ~/.tmux.posh.conf that sets PowerShell as the default shell for newly created windows (on Windows Subsystem for Linux).

5
  • Thank you for helping me explain the mechanism behind the scene, I just tried-and-error without explanation yesterday.
    – Niing
    Commented Apr 13, 2021 at 23:30
  • 1
    @NotTheDr01ds I'm curious: why should a shell function preferred over an alias? What's the benefit? :)
    – mh166
    Commented Mar 13, 2023 at 16:00
  • @mh166 Great question - I wish I could recall what prompted me to type that 2 years ago. Doesn't make any sense to me at this point either! ;-). I'll remove it, and add it back (with explanation) if I remember why I thought that. Thanks! Commented Mar 13, 2023 at 16:04
  • @mh166 Might have just been bad editing on my part, where I started out with something like "alias (preferably) or shell script", added the "shell function" part, and then forgot to remove or move the "(preferably)". That happens to me every so often. Commented Mar 13, 2023 at 16:07
  • @NotTheDr01ds No problem at all, could be me, too. :D Was worth a try though, could've been something new to learn. =]
    – mh166
    Commented Mar 14, 2023 at 17:28

You must log in to answer this question.

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