Skip to content

Instantly share code, notes, and snippets.

@andykais
Last active May 18, 2016 17:37
Show Gist options
  • Save andykais/85e8586ffc46f6bb78c9 to your computer and use it in GitHub Desktop.
Save andykais/85e8586ffc46f6bb78c9 to your computer and use it in GitHub Desktop.
autorun a command when a file is saved
#!/bin/sh
FORMAT=$(echo -e "\033[1;33m%w%f\033[0m written at $(date +'%r')")
clear
while true
do
clear\
&& echo "[Running \"$@\" on files changes in $(pwd) at $(date +'%r')]"\
&& echo ""\
&& echo "$@" > /home/andrew/bin/data/lastroc.sh\
&& bash /home/andrew/bin/data/lastroc.sh 0>/dev/null \
&& sleep .3;
inotifywait -qre close_write --format "$FORMAT" .
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment