Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I currently have an Applescript app that opens Terminal windows and completes commands. I would like a badge icon to appear on the Terminal icon when a command completes. I need this because I often have to restart the commands when they stop. Is this possible? Esentially my Applescript application takes a user inputted variable and plugs it into a Terminal command. Everytime I use the application it opens a new Terminal window (intended). I would like to have a badge icon appear when a Terminal command completes.

share|improve this question
    
Do you require a badge, or would you be happy with the say command verbally alerting you, a beep, a growl notification, the Terminal changing color, or something else? –  user588 Apr 6 '12 at 0:56
    
Any way for me to tell that a command finished. The Terminal windows are always behind all my other windows so it's annoying have to keep checking. I would prefer a notification that stays until I do something though. So a verbal notification probably wouldn't work if I got up and wasn't around. Right? –  Eli Greenberg Apr 6 '12 at 1:23
    
Take the solutions below (probably will be Growl-based) and add an AppleScript line to bring the current window to the foreground. Unfortunately, all Terminals will move to the front (I think), but the window that triggered the event will be in front of all of those. –  user588 Apr 6 '12 at 2:29
    
Note that iTerm2 has triggers which could make this very easy and elegant to set up: iterm2.com/triggers.html –  user588 Apr 6 '12 at 2:56
add comment

2 Answers 2

up vote 11 down vote accepted

As of Mac OS X 10.7 Lion, Terminal has exactly this feature.

If you emit a bell (BEL, Control-G) in a background tab or window, the Terminal application Dock icon will show a badge with the number of “unread” bells

Bell indicator badge in Terminal application Dock icon

and a bell icon is displayed in the tab of the terminal

Bell indicator in background terminal tab

(If there is only one tab in the window, choose View > Show Tab Bar to see the tab, which also displays other status information.)

This also applies to minimized windows.

When you bring the window to the front or select the background tab, the bell indicator is removed from the tab and the badge count goes down.

share|improve this answer
    
Of course this is Lion only, haha. –  Eli Greenberg Apr 6 '12 at 8:32
add comment

If you're willing to accept an answer to the more general question "is there a way to have me alerted when something completes in a Terminal window" then the answer is: yes.

If you're running Growl you can make a command line call from a script that will post a notification to Growl. For example:

do shell script "sleep 1h"
do shell script "growlnotify --sticky --message \"I'm all done sleeping for an hour! Did you forget about me?\" --wait"

The script won't exit until you clear the notification from the screen.

You could even use the --name option to give your script a unique name, and then from within Growl customize how events generated by that named application are displayed and dealt with. They can produce different types of pop ups on the screen, they can email you, they can send a message to you via iChat, they forward the event to Growl on another machine, if you're running Prowl on your iDevice they can even forward the notification on to your iDevice via push notifications.

Not quite the answer you were looking for, but hopefully it meets your needs.

GrowlNotify in action


share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.