进程完成时在 tmux 中发出警报 [英] Alert in tmux when a process completes
问题描述
我可以设置 tmux 以在进程完成时在非活动窗口中触发警报吗?
Can I set tmux to trigger an alert in a non-active window when a process completes?
例如:我开始了一个漫长的构建过程.我希望在完成时收到通知,而不是每次打印状态时都收到通知.
For example: I start a long build process. I would like to be notified when it completes, not each time it prints a status.
推荐答案
我很惊讶还没有给出这个答案:您可以使用 tmux 窗口设置 visual-bell
来解决这个问题.使用 bell-action
,您可以配置是只查看当前窗口的铃声,还是仅显示非当前窗口(其他)的铃声.我个人更喜欢第二种,因为你不会看到 shell 产生的噪音,而且如果它在当前窗口中,你可能不关心通知.
I'm surprised this answer hasn't been given yet: You can use the tmux window setting visual-bell
for this. With bell-action
you can then configure whether you want to see bells for the current window only, or for non-current window only (other). Personally I prefer the second, as you won't see noise generated by the shell, and you probably don't care about the notification if it's in the current window.
set-window-option -g visual-bell on
set-window-option -g bell-action other
当进程产生铃声时,tmux 会高亮显示铃声的窗口标题,并显示窗口 X 中的铃声"通知.
When a process generates a bell, tmux will highlight the the title of the window that rings the bell as well as show a "Bell in window X" notification.
然后在过程结束时按铃.例如:
Then ring the bell at the end of the process. E.g.:
make; echo -e '\a'
(或 &&
||
而不是 ;
如果您只想分别在成功或失败时响铃)
(or &&
||
instead of ;
if you want to ring only on success or failure respectively)
这篇关于进程完成时在 tmux 中发出警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!