Skip to content

Instantly share code, notes, and snippets.

@edi9999
Created September 17, 2015 19:14
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 edi9999/ecf4f9e087318050658f to your computer and use it in GitHub Desktop.
Save edi9999/ecf4f9e087318050658f to your computer and use it in GitHub Desktop.
swatch
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
NORMAL=$(tput sgr0)
swatch() {
[ -a /tmp/swatch ] || touch /tmp/swatch
inotifywait -m -e close_write,moved_to --format %e/%f -r /tmp/swatch |
{ echo "hi" ; while IFS=/ read -r events file; do
echo "$file $events"
done } | while read i
do
printf "exec @$(date "+%H:%M:%S") \n"
printf "'%s' " "$@"
evalthenblink "$@" &
done
}
evalthenblink() {
eval "$@"
res="$?"
if [ "$res" == "0" ]; then
printf "${GREEN}${res}${NORMAL}\n"
else
printf "${RED}${res}${NORMAL}\n"
fi
# This is used to blink the blink-1-tool, use anything else
b "$res"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment