Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Watch your .pug and .jade files
## Save this file into ~/bin and make it writeable (chmod +x pugwatch)
## Execute it from your project folder, e.g. ~/Sites
## It starts up very fast, takes no memory and will instantly compile any
## JADE / PUG files as soon as you create them.
## All dependencies will be installed automatically too.
## Created this because CodeKit (which I purchased) keeps hanging and crashing and being slow for a few years now
# Check for dependencies
which fswatch >/dev/null || brew install fswatch
which terminal-notifier >/dev/null || brew install terminal-notifier
which npm >/dev/null || brew install npm
which pug >/dev/null || npm install pug-cli -g
echo "Watching for .pug and .jade.."
fswatch -e '.*' -i '.jade$' -i '.pug$' . | while read x
pug "$x" \
&& terminal-notifier -group pug -title 'PUG Compiler' -subtitle 'Success' -message "$x" \
|| terminal-notifier -group pug -title 'PUG Compiler' -subtitle 'Failed' -message "$x" -sound Funk -action
#Clicking on notification won't open terminal due to bug:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment