如何在tmux中断开所有其他用户的连接?

253

我有一个tmux会话,因为某个用户连接了,所以窗口太小了。

我该如何告诉tmux断开所有已连接的用户?

3个回答

371
你可以使用<prefix> D(其中默认前缀为C-b),选择要分离的客户端;它还将列出它们的列/行以及最后使用的时间。请注意大写的D,即Shift+d
你也可以使用tmux的detach-client选项。
 detach-client [-P] [-a] [-s target-session] [-t target-client]
               (alias: detach)
         Detach the current client if bound to a key, the client specified
         with -t, or all clients currently attached to the session speci-
         fied by -s.  The -a option kills all but the client given with
         -t.  If -P is given, send SIGHUP to the parent process of the
         client, typically causing it to exit.

无论是通过 <prefix>: 后跟detach [options] 还是在 tmux 内部的命令行中使用 tmux detach [options],都可以分离(detach)当前会话。

25
请注意,这里大写字母D很重要!!(我花了一些令人沮丧的时间才意识到这一点并将当前客户端分离:D) - Simon C.
6
谢谢。我通常会按下[Ctrl-b] [D] [上箭头] [回车]。 - Drew LeSueur
17
在tmux会话中,tmux detach-client -a可以分离除当前客户端之外的所有其他客户端。我经常打错 prefix-D,所以我更喜欢使用这种方式。我甚至有一个函数 detachothers () { tmux detach-client -a; - PEdroArthur
3
如果您之前没有接触过这个词,"majuscule" 意味着 "大写字母"。 - larsks
2
@AlexanderChzhen 只需按一次 'q' 键即可退出选择菜单而不选择要结束的会话。 - demure
显示剩余2条评论

183

tmux a -dt <session-name>

a=attach
d=detach other clients (so only you can attach to this session)
t=target

11

我将从@PEdroArthur的评论中提取出来,单独回答最常见的用例:"在tmux会话中并且希望断开所有其他会话"

从你的tmux会话内部运行以下命令:

tmux detach-client -a

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接