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.
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
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)
There 3 solutions I know, none really ideal. You may put those commands in your ~/.tmux.conf
or just run them directly as Tmux command via Ctrl-B :
.
Monitor and alert whenever the output changes (you may then redirect output somewhere else so that output changes only after the command is complete):
:set -g visual-activity on :setw -g monitor-activity on
Monitor and alert whenever the output did not change for a while (30 seconds here):
:set -g visual-silence on :setw -g monitor-silence 30
(deprecated and someday replaced by a better option) Monitor and alert whevener the output contains a string matching given pattern (and possibly run your command like my-command; echo foobar
):
:set -g visual-content on :setw -g monitor-content foo*bar
$ some-command; tmux display-message "Task 1 done"
. However the message will only show for a short duration defined via :set -g display-time 4000
.
If you keep the visual-*
to off
(default), it'll only highlight the name of the window in which the alert occurred without showing a global alert status message.
For details about each of these settings, see tmux man page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With