Notifications for Long Running bash Tasks
I work in Terminal.app a lot. And one of the things I regularly do is launch a long running task and then go off to do something else (like surf the net or sword flighting)
But I was looking for a way for Terminal to notify me when a long running task has finished. Google and ye shall receive:
alias beep="echo -ne '\007'" # Beep after long running tasks beep_if_long_time_past() { LAST_COMMAND_DURATION=$(($(date +%s) - ${LAST_COMMAND_TIME})) [[ ${LAST_COMMAND_DURATION} -gt 60 ]] && { echo "Last command took ${LAST_COMMAND_DURATION} seconds!"; beep; } export LAST_COMMAND_TIME= } export PROMPT_COMMAND=beep_if_long_time_past trap '[ -z ${LAST_COMMAND_TIME} ] && export LAST_COMMAND_TIME=$(date +%s)' DEBUG
Adding this will send the 'bell' character to the Terminal, even through SSH and screen. The last part of the puzzle is modifying the Terminal.app settings.
Now Terminal will bounce when something longer than 60 seconds finishes and the focus is another application.










