我帮助维护大量类Unix的服务器,因此保留一个名为的脚本tmux-rebuild
,用于重建所有tmux会话和窗口,并通过SSH链接到每个服务器.
我有tmux配置为在该窗口中打印终端铃声字符时,在其状态栏中显示窗口的名称为红色并带有感叹号.这irssi
对于在我在另一个窗口中有消息时提醒我的程序非常方便.
我也在$PS1
每个服务器上设置了在每个提示结束时打印终端铃声的设置.这很有用,因为如果我在一个窗口中运行一个很长的作业并切换到另一个窗口,我可以立即看到它何时完成,因为在作业完成后我的提示写入屏幕时,tmux使窗口名称显示为红色感叹号.这对我的工作流程非常有用.
但是它会导致上面提到的重建脚本出现轻微问题,因为当我在运行它后启动tmux时,每个会话中的每个窗口都会标记为红色,因为第一个提示被打印到屏幕上.这使得该功能在我访问每个窗口之前无用,并且有40-50个这样的东西.
我可以添加到我的脚本中,它会在会话和窗口创建后清除所有警报吗?如果有必要,我不介意使用kludge.
小智 6
找出一个可接受的解决方法; 我重新定义了下一个/上一个绑定以允许重复:
# Allow repeats for next/prev window
bind-key -r n next-window
bind-key -r p previous-window
Run Code Online (Sandbox Code Playgroud)
这允许我通过按下我的前缀键并点击"n"快速扫描会话中所有窗口的警报,直到它们全部清除,然后我回到原来的窗口.
小智 5
从 tmux 手册页,特别是这里的最后一句话:
kill-session [-aC] [-t target-session]
Destroy the given session, closing any windows linked to it
and no other sessions, and detaching all clients attached
to it. If -a is given, all sessions but the specified one is
killed. The -C flag clears alerts (bell, activity, or
silence) in all windows linked to the session.
Run Code Online (Sandbox Code Playgroud)
所以,简单地说:
tmux kill-session -C
Run Code Online (Sandbox Code Playgroud)