Skip to content

Instantly share code, notes, and snippets.

@andy722
Created February 7, 2011 21:54
Show Gist options
  • Save andy722/815316 to your computer and use it in GitHub Desktop.
Save andy722/815316 to your computer and use it in GitHub Desktop.
Runs command in background and shows notification window on completion
#!/bin/bash
_run() {
wd=$PWD
bash -cli "$*"
result=$?
[ $result == 0 ] && description="Successfully executed" || description="Failed with code $result"
cmd=${*:-"Nothing"}
file=`mktemp`
trap "rm $file" EXIT ERR TERM KILL
echo -e "$description:\n" > $file
echo "Command: $cmd" >>$file
echo -n "Directory: $wd" >> $file
LANG=C xmessage -default okay -file $file
rm $file
return $result
}
_run $* &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment