3

We have a centos 7 machine that many developers use with tmux 1.8 under the same user. Is it possible for us to have personal configs for each tmux session, while also leaving the default config intact for new (default) sessions?

2

As @asmodean correctly mentioned, the way to use multiple tmux instances on the same machine (with the same user) is to use two different sockets. A socket name can be given using -L option.

Usage

Create tmux instances

  • first session: tmux -L userA -f ~/.tmux-userA.conf

  • second session: tmux -L userB -f ~/.tmux-userB.conf

Join instances

tmux -L userA attach tmux -L userB attach

Other tmux commands

Other commands work with -L option. For example, to list userA and userB sessions:

tmux -L userA list-sessions tmux -L userB list-sessions

| improve this answer | |
1

Here is what I did to achieve per session configuration in tmux.

set-hook -g after-new-session 'if -F "#{==:#{session_name},emacs}" "source ~/.tmux/.tmux.conf.emacs" "source ~/.tmux/.tmux.conf.amos"'
set-hook -g after-new-window 'if -F "#{==:#{session_name},emacs}" "source ~/.tmux/.tmux.conf.emacs" "source ~/.tmux/.tmux.conf.amos"'
| improve this answer | |
0

tmux can be invoked as tmux -f /path/to/tmux.conf. Since everyone is logging in as the same user, you could create a directory of user configuration files for tmux. For example /home/username/tmux/userA.tmux.conf. UserA would then start their tmux session with:

tmux -f ~/tmux/userA.tmux.conf

If you wanted to simplify thing for the users, you could make alias entries for each user in the ~/.bashrc file for example if you are using bash. Each line would look like:

alias tmuxuserA='tmux -f /home/username/tmux/userA.tmux.conf'

Then userA would invoke their session with the command tmuxuserA.

| improve this answer | |
  • 1
    Sadly, I this doesn't seem to work. As per the man page, "tmux loads configuration files once when the server process has started. The source-file command may be used to load a file later". So -f only works if tmux is fresh and has no running session. Using source updates the config for all running sessions. I feel what I am asking cannot be done using tmux alone. – mcd0well Feb 8 '17 at 13:38
  • 2
    If the users don't need to communicate between sessions, you can use the -L option to specify a socket name. A unique server will be started for each socket, which can use different config files. You can even add it to the alias: alias tmuxuserA='tmux -L userA -f /home/username/tmux/userA.tmux.conf'. – asmodean Apr 28 '17 at 12:24
  • @asmodean, you should add that as it's own answer. Running independent instances on separate sockets is the solution for the stated problem. – user4556274 Feb 21 '18 at 13:30

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.