不同会话的不同 tmux 配置?

mcd*_*ell 6 tmux configuration

我们有一台 centos 7 机器,许多开发人员在同一用户下使用 tmux 1.8 。我们是否可以为每个 tmux 会话设置个人配置,同时为新(默认)会话保留默认配置?

bru*_*ton 7

正如@asmodean 正确提到的,在同一台机器上(使用同一用户)使用多个 tmux 实例的方法是使用两个不同的套接字。可以使用-L选项给出套接字名称。

用法

创建 tmux 实例

  • 第一节: tmux -L userA -f ~/.tmux-userA.conf

  • 第二届会议: tmux -L userB -f ~/.tmux-userB.conf

加入实例

tmux -L userA attach tmux -L userB attach

其他 tmux 命令

其他命令与-L选项一起使用。例如,要列出 userA 和 userB 会话:

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


Amo*_*mos 6

以下是我在 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

  • 如果用户不需要在会话之间进行通信,可以使用“-L”选项指定套接字名称。将为每个套接字启动一个唯一的服务器,它_可以_使用不同的配置文件。您甚至可以将其添加到别名中:`alias tmuxuserA='tmux -L userA -f /home/username/tmux/userA.tmux.conf'`。 (4认同)