How do I make iTerm terminal notify me when a job/process is complete?

前端 未结 7 1782
[愿得一人]
[愿得一人] 2020-12-12 13:00

A notification center notification would be ideal but growl, bounce dock, sound, etc would be fine, too (or if this can only be done in Terminal.app I\'d be willing to switc

7条回答
  •  旧巷少年郎
    2020-12-12 13:14

    You can add any one of the following after any command, with a semi-colon in between the command and it:

    afplay /System/Library/Sounds/Ping.aiff -v 2
    
    osascript -e 'beep 3'
    
    tput bel
    

    or, if you like Notification Centre

    osascript -e 'display notification "Lorem ipsum dolor sit amet" with title "Title"'
    

    You can also make an alias in your profile, called notify and add that at the end of your command. So, in your login profile

    alias notify="tput bel"
    

    then

    sleep 10; notify
    

    Or, if you started your command and it is "hanging", just type notify and hit Enter and it will run your notify alias at the end, whne the command has finished, e.g.

    sleep 20
    
    # wait 5 seconds before realising this will take 20 seconds
    notify
    

提交回复
热议问题