-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvicint
More file actions
executable file
·33 lines (30 loc) · 732 Bytes
/
Copy pathvicint
File metadata and controls
executable file
·33 lines (30 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
## Interactive C in vim (edit, compile, run)
#
# Usage: $0 file.c
#
# - open a file and terminal
# - wait until the file is changed (saved)
# - run a command, default: compile and run
#
# Needs: innotifywait (from inotify-tools)
if ! type -p inotifywait >& /dev/null; then
echo "ERROR: inotifywait not found"
exit 1
fi
fn="$1"
if ! [ -f "$fn" ]; then
echo "File $fn does not exist, creating"
touch "$fn"
fi
out=$(basename "$fn" .c)-cint
while :; do
# Multiple events are sent, the last one is DELETE_SELF
inotifywait -qq -e delete_self "$fn"
# Recreated file can be missing before the command starts
until [ -f "$fn" ]; do
sleep 0.5
done
echo "=== Compile $fn to $out"
gcc -o "$out" "$fn" && "./$out"
done