-
Notifications
You must be signed in to change notification settings - Fork 0
/
watch.zsh
58 lines (50 loc) · 1.71 KB
/
watch.zsh
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
48
49
50
51
52
53
54
55
56
57
58
#!/bin/zsh
function help(){
echo "▶ Report : -r"
echo "▶ Article : -a"
echo "▶ Article within report : -ra"
echo "▶ Documentation : -d"
echo "▶ Verbose mode : -v"
}
function watch(){
latexmk -lualatex -time -silent -pvc -bibtex "src/${1}.tex"
}
# —————————————————————————————————————
# AUX DIR ERROR WORKAROUND
# —————————————————————————————————————
if [ ! -d "./aux_files" ]; then
if [[ $1 == "-v" || $2 == "-v" ]]; then
echo "directory \"./aux_files\" does not exist"
echo "creating directory \"./aux_files\""
fi
mkdir -p "./aux_files"
fi
# ⚠️ | fixing the error : I CANT WRITE TO FILE
# $ | when the include is in a subfolder
content_list=(src/content/*)
# removes "src/"
content_list_trimmed=("${content_list[@]/#src\//}")
for item in "${content_list_trimmed[@]}"; do
if [[ $1 == "-v" || $2 == "-v" ]]; then
echo "checking if directory $item is available in aux_files..."
fi
if [ ! -d "aux_files/$item" ]; then
if [[ $1 == "-v" || $2 == "-v" ]]; then
echo "creating directory $item in aux_files..."
fi
mkdir -p "aux_files/$item"
else
if [[ $1 == "-v" || $2 == "-v" ]]; then
echo "directory $item already exists in aux_files..."
fi
fi
done
# —————————————————————————————————————
case $1 in
"-r") watch "rapport";;
"-a") watch "article";;
"-ra") watch "rapport_article";;
"-d") watch "documentation";;
"-h") help;;
*) help ;;
esac