dotfiles/scripts/prefix/bin/coc

25 lines
457 B
Bash
Executable File

#!/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