Skip to content

Instantly share code, notes, and snippets.

@pykong
Last active October 24, 2019 13:37
Show Gist options
  • Save pykong/7d2c2c058ca4b39069f7c130c4ab60f3 to your computer and use it in GitHub Desktop.
Save pykong/7d2c2c058ca4b39069f7c130c4ab60f3 to your computer and use it in GitHub Desktop.
Execute python script on file change in a directory. Useful when coding to instantly get output from the modified code. Setup: 1) Install inotify: sudo apt-get install inotify-tools 2) Make script executable chmod +x pywatch.sh 3) Make script global
#!/bin/bash
echo watch activated
inotifywait -qmre modify . | while read f
do
python $1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment