Search code examples
tmux

tmux - shared server not in /tmp?


I'm trying to use tmux on an enterprise cluster that dumps /tmp regularly. I want to store the sockets for a shared project in /proj/foo/shells. I can create a session with tmux -S /proj/foo/shells/bar new -s nameOfTheSession, but these do not show up in tmux ls, and I cannot now figure out how to administrate them? Each time I connect with tmux -S /proj/foo/shells/bar a new session is created, which I can kill with ctrl+b x, but now I'm just up to [5].

How do I use tmux this way? I want ls to work properly, and the shells/sessions to behave in a way that I could do tmux a bar and get back into /proj/foo/shells/bar.


Solution

  • Every command has to be given the -S option to tell it which (alternate) socket to use.

    $ tmux -S /proj/new/shells/bar new -s nameOfTheSession
    $ tmux -S /proj/new/shells/bar ls
    

    The command tmux -S /proj/foo/shells/bar does not somehow make every future call to tmux use the given path; it just sends the default command new-session to the server at the given path.

    It seems that you don't care what the name of the actual socket is, as long as it is stored under /proj/foo/shells. In that case, just set TMUX_TMPDIR to your environment:

    export TMUX_TMPDIR=/proj/foo/shells
    

    Now any time you run tmux, it will default to a server available at /proj/foo/shells/default. You can still use the -L option to specify a server name other than default (such as -L bar to use the server /proj/foo/shells/bar instead).