mcd*_*ell 6 tmux configuration
我们有一台 centos 7 机器,许多开发人员在同一用户下使用 tmux 1.8 。我们是否可以为每个 tmux 会话设置个人配置,同时为新(默认)会话保留默认配置?
正如@asmodean 正确提到的,在同一台机器上(使用同一用户)使用多个 tmux 实例的方法是使用两个不同的套接字。可以使用-L
选项给出套接字名称。
第一节:
tmux -L userA -f ~/.tmux-userA.conf
第二届会议:
tmux -L userB -f ~/.tmux-userB.conf
tmux -L userA attach
tmux -L userB attach
其他命令与-L
选项一起使用。例如,要列出 userA 和 userB 会话:
tmux -L userA list-sessions
tmux -L userB list-sessions
以下是我在 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"'
Run Code Online (Sandbox Code Playgroud)
air*_*uff -1
tmux
可以调用为tmux -f /path/to/tmux.conf
. 由于每个人都以同一用户身份登录,因此您可以为tmux
. 例如/home/username/tmux/userA.tmux.conf
。然后,UserA 将启动他们的 tmux 会话:
tmux -f ~/tmux/userA.tmux.conf
Run Code Online (Sandbox Code Playgroud)
如果您想为用户简化操作,您可以为~/.bashrc
文件中的每个用户创建别名条目,例如,如果您使用的是 bash。每行看起来像:
alias tmuxuserA='tmux -f /home/username/tmux/userA.tmux.conf'
Run Code Online (Sandbox Code Playgroud)
然后 userA 将使用命令调用他们的会话tmuxuserA
。