Skip to content

Instantly share code, notes, and snippets.

@seveibar
Last active August 29, 2015 13:56
Show Gist options
  • Save seveibar/9286218 to your computer and use it in GitHub Desktop.
Save seveibar/9286218 to your computer and use it in GitHub Desktop.
Used on my system to run a command on any change in a file in the current directory
#!/bin/bash
# RUN ON CHANGE
if [[ "$unamestr" == 'Linux' ]]; then
while [ 1 ]; do
clear\
&& echo "[Running \"$@\" on files changes in $(pwd) at $(date +'%r')]"\
&& echo ""\
&& echo "$@" > /home/seve/Desktop/lastroc.sh\
&& bash /home/seve/Desktop/lastroc.sh \
&& sleep .3;
inotifywait -r -q -e modify,move,create .;
done
elif [[ "$unamestr" == 'Darwin' ]]; then
while [ 1 ]
do
clear \
&& echo "[Running \"$@\" on files changes in $(pwd) at $(date +'%r')]"\
&& echo ""\
&& $@\
&& sleep .3;
fswatch -r --one-event .;
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment