8

In OS X, when a program wants attention, its Dock icon at the bottom will bounce up and down. In Terminal, sometimes I will run a long series of commands, like this:

a && b && c

I want to append a command at the end of this, that will make the Terminal icon bounce up and down to alert me when these commands have finished running. How can this be done?

2
  • 1
    Why not use Growl and growlnotify?
    – Daniel Beck
    Feb 16, 2011 at 7:47
  • 1
    Please fix the title or text of your question. A bouncing icon is different from a popup alert (dialog), and it's not clear what you want to have.
    – Daniel Beck
    Feb 16, 2011 at 8:33

3 Answers 3

4

BounceTerm may be just what you're looking for. From the web page:

BounceTerm is a SIMBL plugin for Mac OS X's Terminal.app that makes the dock icon bounce when a bell or beep is triggered. This can be useful if you have a long-running process going on and you want to be notified when it's done (assuming it beeps, of course).

No configuration is necessary, just open the .dmg file, run Install, and restart Terminal.app. To uninstall, simply run Uninstall from the .dmg.

If you want to make sure the plugin's working, try running

while [ 1 ]; do echo -n '\a'; sleep 2; done 

in your shell and focusing a window in another application. You should see Terminal.app's dock icon bounce every two seconds.

So for your scenario:

a && b && c && while [ 1 ]; do echo -n '\a'; sleep 2; done
1
  • 3
    I'd just like to point out that, as mentioned in another answer, Terminal does this out of the box, no extra installs necessary, as of OS X 10.7 ("Lion"). Sep 24, 2013 at 18:22
12

As of Mac OS X 10.7 Lion, Terminal bounces its application Dock icon in response to a BEL (Control-G) and a badge displays the number of “unread” bells until you view the relevant terminal(s)†. If the tab bar is visible, it also displays a bell icon in background tabs until you activate them.

† More specifically: it bounces the Dock icon if the Terminal application is in the background at the time the bell occurs, and it displays the bell count for windows and tabs that have not been activated since the bell (whether or not the application as a whole has been activated).

See also Terminal Beeps (output) and Growl.

3
  • 5
    You can test this with something like open -a Finder; sleep 2; printf '\a'.
    – Lri
    Jun 15, 2012 at 10:59
  • 4
    sleep 10; tput bel will work as well
    – Maarten
    Nov 11, 2013 at 2:21
  • Great way to test "apps bouncing in the dock" on demand, thanks!
    – rogerdpack
    Sep 1, 2021 at 17:29
4

As others have pointed out, BounceTerm is no longer required.

However, for me, echo -n did not work. In order for my terminal to bounce, I needed echo -e.

Here is an example. Paste this in Terminal, then quickly Cmd-TAB away to give focus to a different application:

sleep 2; echo -e "\a"

You should hear a boop, your Terminal dock icon should bounce, and you should see a badge that counts the number of bells.

2
  • Bounces OK for me here with sleep 2; echo -n '\a'; FWIW :)
    – rogerdpack
    Sep 1, 2021 at 17:26
  • Pro-Tip: Prefer using printf instead of echo to write control characters. The -n flag is not defined by POSIX. I think printf is usually simpler to use for control characters, as well. In fact, POSIX says, “If the first operand is -n, or if any of the operands contain a <backslash> character, the results are implementation-defined.” <pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html>
    – Chris Page
    Sep 2, 2021 at 20:21

You must log in to answer this question.

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