Created
May 11, 2016 21:37
-
-
Save mattchainsaw/2d6f211647b855056bf6161c587e132c to your computer and use it in GitHub Desktop.
Notification of job completion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# This still works with piping and redirection of output. | |
# Ex) | |
# bash run.sh ./long_computation > long_computation.out | |
if [ ! $1 ] | |
then | |
echo "Usage: $0 <command>" >&2 | |
fi | |
while [ $1 ] | |
do | |
exec 3>&1 | |
notify-send "Job Complete" "Took `(time $1) 2>&1 >&3 3>&-| | |
grep 'real' | sed 's/[^0-9]*//'`" | cat 3>&- | |
exec 3>&- | |
shift | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment