Skip to content

Instantly share code, notes, and snippets.

@mattpolzin
Last active February 2, 2021 02:36
Show Gist options
  • Save mattpolzin/8cb2ec0158c9748a36838f0d034613ba to your computer and use it in GitHub Desktop.
Save mattpolzin/8cb2ec0158c9748a36838f0d034613ba to your computer and use it in GitHub Desktop.
Little script for watching an Idris source directory and building changes.
#!/usr/bin/env sh
if [[ "$1" == "" ]]; then
${SHELL:-bash} $(pwd)/watch_and_learn.sh watch
exit 0
fi
function watch() {
clear
echo "waiting..."
fswatch -E --exclude='(.+\.idr~)|(.+\.swp.*)' -ro ./ | xargs -n1 ./watch_and_learn.sh
}
function learn() {
build_out="$(idris2 --build *.ipkg)"
status="$?"
clear
if [[ "$status" == "0" ]]; then
echo "All good."
else
echo "$build_out"
fi
}
if [[ "$(which fswatch)" == "" ]]; then
echo "fswatch not installed."
echo ""
exit 1
fi
if [[ "$1" == 'watch' ]]; then
watch
else
learn
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment