Last active
August 29, 2015 13:56
-
-
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
This file contains hidden or 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
#!/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