Recipe to see changes in repo in real time

February 27, 2016

Today, I was playing with Markdown in a file for a repository and thought it’d be helpful if I could see my changes in real time (this was a junk repo I was going to delete, so I wasn’t worried about a bunch of commits). Just thought I’d blog this for my own future reference.

Create a script to commit changes and reload Safari…

# Commit changes
git add
git commit -m "formatting"
git push
# Reload Safari
osascript -e 'tell first window of application "Safari" to do JavaScript "window.location.reload(true)" in current tab'

Install fswatch (Mac’s version of inotifywait), a tool to monitor for changes to a file or folder.

brew install fswatch

With the following command, any change to our file will get committed and the page in Safari will be reloaded.

fswatch -o | xargs -n1 ./

Leave a Reply

Your email address will not be published. Required fields are marked *