In irssi, it is easy to enable bells on notifications (mentions, or direct messages) with the following command:


However; this does just that. It sends beeps on highlights, and private messages — regardless of terminal state. Is there a way to continue to receive beeps, but only if the terminal window is not in focus? It does not make much sense to receive beeps in a private chat if you're already actively chatting.

I am using Bash on macOS.

1 Answer 1


It's not easy for an application running in a terminal to know if the terminal is in focus or not. The terminal itself can help you out though.

Here are your options with macOS terminals:

  • Terminal.app

    In Profiles → Advanced → Bell you can turn off the audible bell, but turn on "Bounce app icon when in background".

  • iTerm2

    Similarly to Terminal.app, in Profiles → Terminal → Notifications you can silence the bell and turn on notification center alerts.

If you use tmux you can also change the behavior in your tmux settings. The global option bell-action controls what happens when a bell rings in one of your windows1. By default it is set to any which means that bells will always ring. You can change it to only ring for windows other than the current window with

set -g bell-action other

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .