Skip to content

Instantly share code, notes, and snippets.

@pierrepo
Forked from thisirs/gist:4655411
Last active December 11, 2015 21:48
Show Gist options
  • Select an option

  • Save pierrepo/4665305 to your computer and use it in GitHub Desktop.

Select an option

Save pierrepo/4665305 to your computer and use it in GitHub Desktop.
# 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