Skip to content

Instantly share code, notes, and snippets.

@Riebart
Created April 13, 2017 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Riebart/8436a5abdd329aad48d3c6962142b510 to your computer and use it in GitHub Desktop.
Save Riebart/8436a5abdd329aad48d3c6962142b510 to your computer and use it in GitHub Desktop.
A bash function that sends a pushbullet notification when a command completes
function pb_notify {
start=`date +%s%N`
"$@"
end=`date +%s%N`
start_ms=`echo $start | head -c 13`
end_ms=`echo $end | head -c 13`
dt_ms=$[(end_ms-start_ms)]
if which bc >/dev/null 2>&1
then
dt=`echo "scale=3;$dt_ms/1000.0" | bc`
else
dt=$[dt_ms/1000]
fi
pb push "Command completed at `date` in $dt seconds"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment