Alert in tmux when a process completes

John picture John · May 20, 2014 · Viewed 11.6k times · Source

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.

Answer

wump picture wump · Aug 27, 2016

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)