-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunner.sh
More file actions
47 lines (40 loc) · 1.22 KB
/
Copy pathrunner.sh
File metadata and controls
47 lines (40 loc) · 1.22 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# FULL-AUTOMATIC MODIFIED SCRIPT EXECUTER FOR FAIL-ORIENTED SCRIPTERS AND GIFTED KIDS
#
# Run this in a seperate terminal to automate running your
# script/code/etc. whenever you save it
#
# ./runner.sh <command-to-run> <file_to_track> <arguments>
#
# 2nd arg is always expected the file to be tracked.
#
# Examples:
# ./runner.sh python3 test.py -t=all --foo=bar
# ./runner.sh bash script.sh
# ./runner.sh nasm code.asm # nifty live assembler
# ./runner.sh "gcc main.c && ./a.out" "main.c" # nifty live compiler
#
# Autosave command for vim :autocmd TextChanged,TextChangedI <buffer> silent write
TRIAL=0
doit() {
# run
$@
# print
TRIAL=$(($TRIAL+1))
COLS=$(tput cols)
COLOR=$(tput setaf $(($TRIAL % 10 + 1)))
NC=$(tput sgr0)
printf "${COLOR}%0.s-${NC}" $(seq $COLS)
printf "\n"
printf "${COLOR}%0.s ${NC}" $(seq $(($COLS/2 - 6)))
printf "${COLOR}TRIAL #$TRIAL END\n${NC}"
printf "${COLOR}%0.s-${NC}" $(seq $COLS)
printf "\n"
}
# run it in the beginning once
doit $@
# run it on file modification
while (inotifywait -q -e close_write $2 > /dev/null)
do
doit $@
done