Created
September 17, 2015 19:14
-
-
Save edi9999/ecf4f9e087318050658f to your computer and use it in GitHub Desktop.
swatch
This file contains 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
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