dotfiles/scripts/prefix/bin/coc

25 lines
457 B
Text
Raw Normal View History

2016-03-18 17:59:50 +01:00
#!/bin/sh
#
# "coc" stands for "compile on change" and runs the supplied compile
# command when the given list of files is changed.
#
# coc [command] [fileToCompile] [filesToWatch]
#
# If no explicit list of files to watch is given, fileToCompile is
# watched.
command=$1
file=$2
shift 2
watchedFiles=$@
if [ -z "$watchedFiles" ] ; then
watchedFiles=$file
fi
while true ; do
date
inotifywait -e modify $watchedFiles
$command $file
done