Skip to content

Instantly share code, notes, and snippets.

@tensorturtle
Last active June 11, 2021 04:24
Show Gist options
  • Select an option

  • Save tensorturtle/43dffce0736ea63f4a016319e276246a to your computer and use it in GitHub Desktop.

Select an option

Save tensorturtle/43dffce0736ea63f4a016319e276246a to your computer and use it in GitHub Desktop.
Compile .cpp on write
#!/bin/bash
# start this script in one window, passing in .cpp file as argument
# open text editor in another window
# when you make edits and save file in the text editor, this script will run to compile and run the C++ code
inotifywait -e close_write,moved_to -m . |
while read -r directory events filename; do
if [ "$filename" = "$1" ]; then
g++ "$1"
./a.out
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment