Skip to content

Instantly share code, notes, and snippets.

@drosenstark
Created April 21, 2019 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drosenstark/a9ba254800b04a6a8cc66182b8bfaf8c to your computer and use it in GitHub Desktop.
Save drosenstark/a9ba254800b04a6a8cc66182b8bfaf8c to your computer and use it in GitHub Desktop.
Watch and Swift file and run it on change
#!/bin/sh
# swiftWatchAndRun
if [ $# -ne 1 ]; then
echo "Use like this:"
echo " $0 filename-to-watch"
exit 1
fi
if which fswatch >/dev/null; then
echo "Watching swift file $1"
while true; do fswatch --one-event $1 >/dev/null && echo "----------------"; echo `date +"%m-%d-%y %I:%M%p"`; echo "----------------" && swift $1; sleep 0.1; done
else
echo "You might need to run: brew install fswatch"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment