我如何启动一个完全独立的 tmux 新实例?

Pab*_* C. 5 linux terminal tmux

如果我已经打开了一个 tmux 会话,结果是我无法使用另一个 tmux 配置启动新的会话,即:

$ tmux # loads new session using ~/.tmux.conf
Run Code Online (Sandbox Code Playgroud)

在另一个航站楼...

$ tmux -f another.tmux.conf
( load the same tmux configuration )
Run Code Online (Sandbox Code Playgroud)

我尝试使用tmux -f another.tmux.conf new-session -s another,但它也不起作用。

Pab*_* C. 6

这里的关键是,即使您打开一个新会话,它们也都属于同一个“服务器”。解决这个问题的唯一方法似乎是使用另一个套接字:

tmux -f another.tmux.conf -L new-socket
Run Code Online (Sandbox Code Playgroud)

如果您想列出新实例的会话,则必须添加指定的套接字,否则将仅列出默认套接字。

tmux -L new-socket list-sessions
Run Code Online (Sandbox Code Playgroud)

此信息的相关部分位于tmux 手册页的参数描述下:

-L socket-name
               tmux stores the server socket in a directory under
               TMUX_TMPDIR, TMPDIR if it is unset, or /tmp if both are
               unset.  The default socket is named default.  This option
               allows a different socket name to be specified, allowing
               several independent tmux servers to be run.  Unlike -S a
               full path is not necessary: the sockets are all created in
               the same directory.

               If the socket is accidentally removed, the SIGUSR1 signal
               may be sent to the tmux server process to recreate it.
Run Code Online (Sandbox Code Playgroud)

这意味着您无法在两个不同的 tmux 实例之间进行通信(据我所知)。