Announce When a Command Line Task is Completed in Mac OS X

May 8, 2012 - 15 Comments

Announce the completion of a command in Mac OS X Terminal

By appending the say command to the end of another command, Mac OS X will vocally announce when the initial task has finished running successfully. For example, to have OS X announce that a particular script has finished running the command could be:

python && say "jobs done"

The important part is the “&& say” portion, which can also be customized with other voices from Mac OS X’s text to speech options by using the -v flag followed by a voice name, like so:

dscacheutil -flushcache && say -v Alex your cache has been cleared sir

This is perfect for running scripts, making svn/git commits, compiling code, and other tasks that can take an indeterminate amount of time to complete and where it’s easy to become distracted by facebook^H^H^H^H^H^H^H^H other work.

This great tip was posted by @niels on Twitter, follow @osxdaily there too to get our latest posts and updates.


Related articles:

Posted by: William Pearson in Command Line, Mac OS, Tips & Tricks


» Comments RSS Feed

  1. […] This has a myriad of potentially valid uses, but one fantastic use-case is along the same veins of verbally announcing when a command has completed or sending a badge alert, but instead posting the notification to OS X Mountain Lion’s […]

  2. […] long ago we showed you how to announce when a command line task was finished by using the ‘say’ command, but because it speaks aloud it may be inappropriate to use […]

  3. […] the lines of vocally announcing task completion within the command line, you can also have Mac OS X speak the output of any executed […]

  4. The Zerafiall says:

    Haha… I read the tweet and clicked the link and was thinking “Oh… maybe it’s some fancy way of invoking growl or a UIAlertVeiw. Wait… wouldn’t be easier to just add && say -v Task Done to the end of you code” only to come over here and see that’s exactly what you did XD

  5. rev_1318 says:

    the only drawback for using ‘&&’ is that you won’t get a notification if the command fails!
    Why not simply use ‘;’ as command separator?


    cd IDontExist && say -v Alex Oops


    cd IDontExist; say -v Alex Oops

  6. vdiv says:

    Excellent! Alex even gets the intonation right. Put a question mark at the end and hear for yourself.

  7. Foobar says:

    Nope, not for the finder. For the terminal, it’d be
    $cp foo bar && say “file transfer complete”

  8. Ken says:

    so…is it possible to make a notification when file transfer from finder is done? How to do it?

  9. Greg P says:

    You can also pipe to say

    I tried it with uptime as follows

    uptime | say

    The Mac told me the time, uptime, load average etc

    Very cool little function


  10. Theo Vosse says:

    You could also try “growlnotify”, e.g. like this
    $ growlnotify -s -m “Task Done”

    • Jason says:

      Agreed, growl is a superior solution for anyone in an office, and you can use -H to specify alternate hosts to receive the notification.

  11. Tarcisio says:

    My function to say the task status

    function sayTaskStatusUsingExitCode() {
    if [ “$?” == “0” ]
    say -v Alex “Task Ok”
    say -v Alex “Task Error”

    • xofer says:

      You don’t need a function for that.

      You can do: && say -v Alex “Task Ok” || say -v Alex “Task Error”

      • xofer says:

        And, by the way “&&” is wrong in the article itself – this is logical AND, which means the the latter part is executed *only* if the first part exited with a zero exit status.

        It would make much more sense to do:
        python; say “jobs done”

        Then the second command is executed no matter what the exit code of the first.

Leave a Reply


Shop on and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks


iPhone / iPad



Shop on Amazon to help support this site