Skip to content

Instantly share code, notes, and snippets.

@angel-rs
Created July 5, 2020 21:57
Show Gist options
  • Save angel-rs/43b1220ab4f7e5c80e1c6c49deeb6790 to your computer and use it in GitHub Desktop.
Save angel-rs/43b1220ab4f7e5c80e1c6c49deeb6790 to your computer and use it in GitHub Desktop.
Run a c file program on every file save
  • create your "x.c" file
  • create "run.sh" file with the following:
# run for the first time
gcc x.c
./a.out


inotifywait -q -m -e close_write examen.c |
while read -r filename event; do
  # run after tweaking the file
  gcc x.c
  ./a.out
done
  • chmod +x ./run.sh
  • sh run.sh
  • Hack away in your editor, now the C file will run on every file change
@mikehathsin
Copy link

Necessary dependency

sudo apt install inotify-tools -y

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment