The bounce is caused by the ASCII bell control code, number 7. By echoing the
\a special character you send an alert to the terminal window.
When the window is on the foreground it can sound a tone or flash the window to signal you about an event. But when it is out of focus the Terminal icon in the Dock will bounce and display a notification badge with the message count.
echo -e '\a'
-e is important because without it the
a character will be escaped and therefor no longer be special.
You can repeat the
\a in a string to send double bounces. However, this won’t increase the badge count.
echo 'Click another window and watch the Dock' \ && sleep 2 \ && echo -e '\a'