Skip to content

Instantly share code, notes, and snippets.

@thisirs
Created January 28, 2013 13:15
Show Gist options
  • Save thisirs/4655411 to your computer and use it in GitHub Desktop.
Save thisirs/4655411 to your computer and use it in GitHub Desktop.
Alert user that a job finished
# Alert user that a job finished:
# lengthycmd; alert
# or
# lengthycmd
# <CTRL-Z>
# fg; alert
function alert() {
JOB=$(history 1)
if [[ "$JOB" == *fg\;* ]]
then
JOB=$(history 2 | head -n1)
fi
JOB=$(echo $JOB | sed -e "s/^\s*[0-9]\+\s*//" -e "s/;\s*alert$//")
notify-send -i terminal "Task finished" "$JOB"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment