-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenShennong.sh
executable file
·551 lines (519 loc) · 22.3 KB
/
OpenShennong.sh
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
#!/bin/bash
#
# 神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农
# 神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农
# 神农 神农
# 神农 神农
# 神农 神农
# 神农 神农
# 神农 神农
# 神农 神农
# 神农 .d88888b. .d8888b. 888 神农
# 神农 d88P" "Y88b d88P Y88b888 神农
# 神农 888 888 Y88b. 888 神农
# 神农 888 88888888b. .d88b. 88888b. "Y888b. 88888b. .d88b. 88888b. 88888b. .d88b. 88888b. .d88b. 神农
# 神农 888 888888 "88bd8P Y8b888 "88b "Y88b.888 "88bd8P Y8b888 "88b888 "88bd88""88b888 "88bd88P"88b 神农
# 神农 888 888888 88888888888888 888 "888888 88888888888888 888888 888888 888888 888888 888 神农
# 神农 Y88b. .d88P888 d88PY8b. 888 888Y88b d88P888 888Y8b. 888 888888 888Y88..88P888 888Y88b 888 神农
# 神农 "Y88888P" 88888P" "Y8888 888 888 "Y8888P" 888. 888 "Y8888 888 888888 888 "Y88P" 888 888 "Y88888 神农
# 神农 888 888 神农
# 神农 888 Y8b d88P 神农
# 神农 888 OpenShennong "Y88P" 神农
# 神农 LaTeX Project Manager 神农
# 神农 神农
# 神农 神农
# 神农 神农
# 神农 神农
# 神农 神农
# 神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农
# 神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农神农
#
source ~/Repositories/scripts/essential-functions
data_dir="$XDG_DATA_HOME/OpenShennong"
local_registry="$data_dir/projects.csv"
# non-interactive functions
function conf-info-extract {
runcase-dealer only 0
cat project.conf | grep "^$1 = " | awk -F ' = ' '{print $NF}'
}
function goto-project {
# doesn't work, more fucking subshell bullshit again.
[[ "$(cat "$local_registry" | wc -l)" = 0 ]] && {
echolor yellow ":: No projects in local data file."
return 1
}
intended_target="$(xsv select 1 "$local_registry" | fzf)"
[[ -z "$intended_target" ]] && {
echolor yellow ":: Nothing selected."
return 1
}
cd "$(grep "^$intended_target," "$local_registry" | xsv select 2)" \
&& echolor green-neonblue ":: Welcome to ““$intended_target”” at ““$(pwd)””." \
&& list-project-files \
|| echolor yellow-neonblue ":: Failed to go to ““$intended_target””"
}
function list-project-files {
runcase-dealer not F
case $runcase in
1) case "$1" in
"year") ;;
*) eza -lX --icons --no-user --time-style=iso --sort=newest --color-scale all && exit ;;
esac
;;
2) eza -lX --icons --no-user --time-style=iso --sort=newest --color-scale all && exit ;;
# F) goto-project ;;
0) runcase-dealer only 0
eza -lX --icons --no-user --time-style=iso --sort=modified --color-scale all --color=always \
--group-directories-first --no-quotes --no-permissions --git -I "*log|*aux|*toc|*conf|*blg|*bbl|set.sh" ;;
*) echolor yellow ":: list-project-files: Unknown runcase." && exit ;;
esac
}
function runcase-determiner {
# runcase F is when there's no TeX project in sight
# runcase 0 is the main TeX project
# runcase 1 is the project/papers dir
# runcase 2 is the project/images dir
#
# to define other runcases, add another other-runcases definition in this
# function, and a goto location in runcase-dealer goto
#
fd -q -d 1 "project.conf" && export runcase="0" || export runcase="F"
function other-runcases {
[ -z "$1" ] && echolor yellow ":: other-runcases: No search term for definition." && exit
[ -z "$1" ] && echolor yellow ":: other-runcases: No runcase number for definition." && exit
if [ "$(pwd | awk -F '/' '{print $NF}')" = "$1" ]; then
fd -q -d 1 "project.conf" .. && export runcase="$2"
fi
}
other-runcases papers 1
other-runcases images 2
}
function runcase-dealer {
runcase-determiner
[[ -z "$1" ]] && {
echolor yellow ":: runcase-dealer: No valid command."
return 1
}
[[ -z "$2" ]] && {
echolor yellow ":: runcase-dealer: No valid parameter."
return 1
}
case "$1" in
"only") [[ "$runcase" != "$2" ]] && {
echolor yellow ":: Can’t do that in this directory (only $2)."
return 1
} ;;
"not") [[ "$runcase" = "$2" ]] && {
echolor yellow ":: Can’t do that in this directory."
return 1
} ;;
*) echolor yellow ":: Unknown runcase-dealer command." ;;
# "goto")
# # doesn't work. anchor function problem.
# [ -z "$ANCHOR_DONE" ] && echolor yellow ":: Please anchor project first." && exit
# case "$2" in
# 0) cd "$PROJECT_DIR" ;;
# 1) cd "$PROJECT_DIR"/papers ;;
# 2) cd "$PROJECT_DIR"/images ;;
# *) echolor yellow ":: runcase-dealer: unknown runcase." && exit ;;
# esac
# ;;
esac
}
function save-to-local {
runcase-dealer only 0
project_name="$(conf-info-extract project_name)"
project_dir="$(conf-info-extract project_dir)"
[[ ! -e "$data_dir" ]] && mkdir "$data_dir"
touch "$local_registry"
grep -q ",$project_dir$" "$local_registry" \
&& echolor yellow-neonblue ":: A project with the path ““$project_dir”” already exists." \
&& exit
echo "$project_name,$project_dir" >> "$local_registry" \
&& echolor green ":: Project recorded at $data_dir"
}
function remove-from-local {
# $1 should be a project_dir
[[ ! -e "$local_registry" ]] && mkdir "$data_dir"
touch "$local_registry"
grep -q "$1" "$local_registry" || {
echolor yellow ":: Project not recorded at $data_dir"
return 1
}
old_project_dir="$1"
grep -v "$old_project_dir$" "$local_registry" > "$local_registry".temp
mv "$local_registry" "$local_registry"-$(date +%Y%m%d%H%M%S)
mv "$local_registry".temp "$local_registry" \
&& echolor green ":: Project removed from $data_dir"
}
function remove-from-local-prompt {
[[ ! -e "$local_registry" ]] && mkdir "$data_dir"
touch "$local_registry"
selected_project="$(xsv select 1 "$local_registry" | fzf --prompt="Choose project to remove from local registry: ")"
[[ -z "$selected_project" ]] && {
echolor yellow ":: Nothing selected."
return 1
}
echolor green-neonblue ":: Do you want to remove ““$selected_project”” from the local registry? (y/N) " 1
read -r remove_p
[[ "$remove_p" != "y" ]] && {
echolor yellow ":: Nothing done."
return 1
}
sed -i "/^$selected_project,/d" "$local_registry" \
&& echolor green-neonblue ":: Project ““$selected_project”” removed from local registry."
}
function show-local-registry {
bat -Pn "$local_registry"
}
function update-project-info-file {
runcase-dealer only 0
project_name="$(conf-info-extract project_name)"
project_dir="$(conf-info-extract project_dir)"
[[ "$(pwd)" != "$project_dir" ]] && {
sed -i "/^project_dir /d" project.conf
echo "project_dir = $(pwd)" >> project.conf
echolor green-neonblue ":: Old directory: ““$project_dir””"
echolor green-neonblue ":: New directory: ““$(pwd)””"
remove-from-local "$project_dir"
echolor green ":: Please run anchor again."
} || {
echolor green ":: Project info already up-to-date."
}
# TODO: also add check for project name
# TODO: add parameter in project.conf to indicate whether project is in local registry
update-reading-notes-file
}
function update-reading-notes-file {
runcase-dealer only 0
for j in $(eza -1X "$(pwd)/papers")
do
grep -q "\[\[file:papers/$j\]" reading-notes.org && continue
echo "* [[file:papers/$j][${j/.pdf/}]]" >> reading-notes.org
echolor green-aquamarine ":: Added ““${j/.pdf/}”” to reading notes file!"
done
for j in $(eza -1X "$(pwd)/papers")
do
grep -q "\[\[file:papers/$j\]" paper-summaries.org && continue
echo "* [[file:papers/$j][${j/.pdf/}]]" >> paper-summaries.org
echolor pink-aquamarine ":: Added ““${j/.pdf/}”” to paper summaries file!"
done
}
function check-dependencies {
dependencies=("texlive-xetex" "texlive-bibtexextra" "texlive-binextra" "eza" "fd" "sioyek" "xsv" "bat" "pdfgrep")
# continue this later
}
# interactive functions
function create {
runcase-dealer only F
[[ -z "$1" ]] && {
echolor yellow ":: Please enter project name."
return 1
}
fd -d 1 -q "^$1$" && {
echolor yellow ":: Clobber prevented. Choose a different name."
return 1
}
xsv select 1 "$local_registry" | grep -q "$1" && {
echolor yellow-neonblue ":: ““$1”” already exists. Choose a different name."
return 1
}
name="$1"
x=0
cp -nr ~/Misc/templates/latex/ ./"$name" \
&& echolor green ":: Template copied." \
|| echolor yellow ":: Template not copied."
sed -i "s/REPLACEHERE/$name/g" ./"$name"/set.sh && ((x++))
mv -n ./"$name"/template.tex ./"$name"/"$name".tex && ((x++))
[[ "$x" = 2 ]] && echolor green ":: All parameters replaced." || echolor yellow ":: Not all parameters replaced."
cd ./"$name" || exit
echo -e "project_name = $name" >> project.conf
echo -e "project_dir = $(pwd)" >> project.conf
[[ "$x" = 2 ]] && {
xelatex -interaction=batchmode ./"$name".tex
echolor green ":: LaTeX files initialized."
((x++))
}
[[ "$x" = 3 ]] && {
save-to-local
echolor purple-neonblue ":: Welcome to your project: ““$name.””"
}
}
function see-pdf-file {
runcase-dealer only 0
filename="$(conf-info-extract "project_name")"
[[ -z "$filename" ]] && {
echolor yellow ":: Project name not found in .conf file."
return 1
}
[[ -e "$filename.pdf" ]] && {
sioyek "$filename".pdf 2>/dev/null >/dev/null
} || {
echolor yellow-neonblue ":: PDF file ““$filename.pdf”” not found."
}
}
function pdfgrep-term-freq {
runcase-dealer only 0
[[ -z "$1" ]] && echolor yellow ":: Please enter a search term."
echo "$1" | grep -q '/' && {
echolor yellow ":: Lookup term cannot contain /."
return 1
}
lookup_file="./.lookups/lookup.$1.shennong"
fd -qu lookup."$1".shennong ./.lookups && {
echolor green ":: Previous lookup found! To refresh, use the 'relookup' command."
bat -p "$lookup_file"
return 1
}
echolor green ":: Working..."
pdfgrep --color=always -ic "$1" papers/* \
| sed '/0$/d;s/:/,/g' \
| xsv select 2,1 2>/dev/null \
| sort -V \
| tac \
> "$lookup_file"
[[ "$(cat "$lookup_file" | wc -l)" -eq 0 ]] && {
echolor yellow ":: No results found!" > "$lookup_file"
}
bat -p "$lookup_file"
}
function pdfgrep-term-freq-again {
runcase-dealer only 0
[[ -z "$1" ]] && echolor yellow ":: Please enter a search term."
echo "$1" | grep -q '/' && {
echolor yellow ":: Lookup term cannot contain /."
return 1
}
lookup_file="./.lookups/lookup.$1.shennong"
[[ -e "$lookup_file" ]] && {
echolor green ":: $(mv -nv "$lookup_file" "./.lookups/.archive/lookup.$1.$(date +%Y%m%d%H%M%S).shennong") "
} || {
echolor yellow ":: No such previous lookup."
}
pdfgrep-term-freq "$1"
}
function project-info {
runcase-dealer only 0
bat -Ppf -l conf ./project.conf
}
function show-help {
echo -e " \
Available commands: \n\
\t\033[37mcreate\033[0m: Creates a new project. \n\
\t\033[37msee\033[0m: Views the project’s PDF file.\n\
\t\033[37mset\033[0m: Sets the project’s TeX file using XeTeX. \033[37m[1, 3, N/A]\033[0m\n\
\t\033[37mhelp\033[0m: Shows this help message. \n\
\t\033[37mcount\033[0m: Counts stats of the project’s TeX and BiB files. \n\
\t\033[37minfo\033[0m: Shows the project’s info from the project.conf file. \n\
\t\033[37mdl\033[0m: Downloads paper from sci-hub by DOI number. \n\
\t\033[37manchor\033[0m: Save project path to local registry. \n\
\t\033[37munanchor\033[0m: Remove project path from local registry. \n\
\t\033[37mshowall\033[0m: Show all projects currently in local registry. \n\
\t\033[37mrename\033[0m: Renames directory and/or project. \033[37m[project, dir]\033[0m\n \
\t\033[37mlookup\033[0m: Uses pdfgrep to find search term in all papers. \n\
\t\033[37mrelookup\033[0m: Ditto, but doesn’t resort to cached lookup files."
}
function set-tex-file {
runcase-dealer only 0
./set.sh "$1"
}
function count-all {
runcase-dealer only 0
filename="$(conf-info-extract "project_name")"
blg_used="$(grep -i "You've used" "$filename".blg | awk -F ' ' '{print $3}')"
bib_count="$(grep "@" refs.bib | wc -l)"
allpapers=($(grep '@' refs.bib | awk -F '{' '{print $NF}' | sed 's/,$//g'))
i=0
unused=0
undownloaded=0
commented=0
echolor green ":: These are your unused papers:"
while [[ "$i" -le "${#allpapers[@]}" ]]; do
thispaper="${allpapers[$i]}"
filename="$(conf-info-extract "project_name")"
((i++))
grep -q "$thispaper" "$filename".bbl && continue
undwarning=""
if ! fd -q "^$thispaper".pdf ./papers; then
undwarning=" \t\033[33m<--- UNDOWNLOADED\033[0m"
((undownloaded++))
((unused--))
fi
if grep -qF "% ~\\ci{$thispaper}" "$filename".tex; then
[[ -z "$undwarning" ]] && {
undwarning="\033[35m✓\033[0m"
} || {
undwarning=" \t\033[33m<--- COMMENTED but UNDOWNLOADED\033[0m"
}
((commented++))
fi
[[ -z "$undwarning" ]] && undwarning=" \t\033[34m<--- UNCOMMENTED\033[0m"
echo -e "$thispaper $undwarning" && ((unused++))
done
allpapers=($(eza -1X ./papers | sed 's/\.pdf//g')) # reuse allpapers to list all pdfs
i=0
unbibbed=0
while [[ "$i" -le "${#allpapers[@]}" ]]; do
thispaper="${allpapers[$i]}"
((i++))
grep -q "$thispaper," refs.bib && continue
echo -e "$thispaper \t\033[31m<--- UNBIBBED\033[0m"
((unbibbed++))
done
echolor green-neonblue ":: Bib file stats: ““$bib_count”” entries, of whom ““$blg_used”” are in use, ““$unused”” unused (““$commented”” commented), ““$undownloaded”” undownloaded, and " 1
echolor green-red "““$unbibbed”” unbibbed papers."
allcalc=$((blg_used + unused + undownloaded - unbibbed))
[[ "$allcalc" -ne "$bib_count" ]] && {
echolor yellow-neonblue ":: Something went wrong. The sum ““$allcalc”” is different than the Bib file number ““$bib_count””."
}
echolor green-neonblue ":: TeX file stats: ““$(texcount -1 -utf8 -ch -q "$filename".tex)””"
}
function download-paper {
echolor green ":: Starting PDF retrieval..."
[[ -z "$1" ]] && {
echolor red ":: No DOI entered."
return 1
}
indoi="$(echo "$1" | sed 's|https://doi.org/||')"
echolor green-neonblue ":: Going to ““https://sci-hub.ru/$indoi””"
shurl="$(curl -s "https://sci-hub.ru/$indoi")"
echolor green ":: Sci-Hub queried!"
echo "$shurl" | grep -q "doesn't have the requested document" && {
echolor yellow ":: Sci-Hub does not have this file."
return 1
}
echo "$shurl" | grep -q "Checking your browser" && {
echolor yellow ":: Caught in evil CAPTCHA hell. Please inform the website that you’re an honest researcher and retry."
return 1
}
ddurl="$(echo "$shurl" | grep -i 'application/pdf' | awk -F 'src="' '{print $2}' | awk -F '#' '{print $1}' | tr -d "\n" | sed 's|https://||;s|^//||')"
for j in "downloads" "uptodate" "tree"
do
echo "$ddurl" | grep -q "$j" || continue
ddurl="$(echo "$ddurl" | sed "s|^/$j|sci-hub.ru/$j|")"
done
[[ -z "$2" ]] && bibname="unnamed" || bibname="$2"
fd -q "$bibname".pdf && {
echolor yellow-neonblue ":: Paper ““$bibname”” already exists. Overwrite? (y/N) " 1
read -r overwrite_p
[[ "$overwrite_p" = y ]] && echolor green ":: $(rm -vf "$bibname".pdf)" || return 1
}
[[ -z "$ddurl" ]] && {
echolor red ":: Unknown fatal error."
return 1
}
wget --load-cookies="$browser_cookies" -nc -O ./"$bibname".pdf -t 0 -- https://"$ddurl" && touch -c ./"$bibname".pdf
}
function fetch-bib-citation {
[[ -z "$1" ]] && return 1
[[ -z "$EMAIL" ]] && {
echolor red ":: Email variable not found. Exiting."
return 1
}
tmp_bib="/tmp/tmp-bib-$(date-string)"
echolor green ":: Starting bib retrieval..."
echolor green-neonblue ":: Going to ““https://api.citeas.org/product/$1?email=$EMAIL””"
curl -s "https://api.citeas.org/product/$1?email=$EMAIL" | jq -r '.exports.[] | select( .export_name == "bibtex" ) | .export' > "$tmp_bib"
echolor green ":: Citeas.org queried!"
sed -i 's/journal-article/article/g;s/,,/,/g;s/title={/title={{/g;s/title=/\ntitle=/g;/title=/s/}/}}/g' "$tmp_bib"
authorkey="$(grep 'author=' "$tmp_bib" | sed 's/Al-//g;s/al-//g;s/Al //g' | tr -d '-' | awk -F '{' '{print $2}' | awk -F '}' '{print $1}' | awk '{print $1}' | tr '[:upper:]' '[:lower:]' | tr -d ',')"
yearkey="$(grep 'year=' "$tmp_bib" | awk -F '{' '{print $2}' | awk -F '}' '{print $1}')"
titlekey="$(grep 'title=' "$tmp_bib" | awk -F '{{' '{print $2}' | awk -F '}}' '{print $1}' | sed 's/^A //;s/^An //;s/^The //;s/-/ /g' | awk '{print $1}' | tr '[:upper:]' '[:lower:]')"
bibkey="$authorkey$yearkey$titlekey"
sed -i "s/ITEM1/$bibkey/" "$tmp_bib"
}
function fetch-bib-no-add {
fetch-bib-citation "$1" || return 1
bat -Ppl bib "$tmp_bib"
}
function add-bib-citation-to-refs {
runcase-dealer only 1
fetch-bib-citation "$1" || return 1
grep -q "{$bibkey," ../refs.bib && {
echolor red-neonblue ":: Article ““$bibkey”” already exists in refs.bib. Not adding."
} || {
bat -Ppl bib "$tmp_bib"
cat "$tmp_bib" >> ../refs.bib
echo >> ../refs.bib
}
}
function get-bib-and-download-paper {
runcase-dealer only 1
add-bib-citation-to-refs "$1" || return 1
[[ -z "$bibkey" ]] && {
echolor red ":: Bibkey not found."
return 1
}
echolor green-neonblue ":: Downloading paper as ““$bibkey””"
download-paper "$1" "$bibkey"
}
function rename-stuff {
runcase-dealer only 0
[[ -z "$1" ]] && {
echolor yellow ":: rename-stuff: No valid command."
return 1
}
[[ -z "$2" ]] && {
echolor yellow ":: rename-stuff: No valid parameter."
return 1
}
function rename-directory {
current_name="$(pwd | awk -F '/' '{print $NF}')"
cd ..
mv -n "$current_name" "$1" || echolor yellow ":: Move failed. Probably clobber."
cd "$1" || exit
}
case "$1" in
"dir")
project_name="$(conf-info-extract project_name)"
project_dir="$(conf-info-extract project_dir)"
remove-from-local "$project_dir"
rename-directory "$2"
sed -i "s|$project_dir|$(pwd)|g" ./project.conf
save-to-local
echolor green-neonblue ":: Directory renamed to ““$2””"
;;
"project")
project_name="$(conf-info-extract project_name)"
project_dir="$(conf-info-extract project_dir)"
grep -q "^$2," "$local_registry" \
&& echolor yellow ":: A project with that name already exists." \
&& exit
remove-from-local "$project_dir"
rename -va "$project_name" "$2" ./*
rename-directory "$2"
runcase-dealer only 0
sed -i "s|project_name = $project_name|project_name = $2|g" ./project.conf
sed -i "s|project_dir = $project_dir|project_dir = $(pwd)|g" ./project.conf
sed -i "s|project_name=\"$project_name\"|project_name=\"$2\"|g" ./set.sh
save-to-local
echolor green-neonblue ":: Project renamed to ““$2””"
;;
*)
echolor yellow ":: Unknown runcase-dealer command." ;;
esac
}
check-dependencies
[[ -z "$1" ]] && list-project-files && exit
comd="$1"
case "$comd" in
"create") create "$2" ;;
"see") see-pdf-file ;;
"set") set-tex-file "$2" ;;
"help") show-help;;
"count") count-all ;;
"info") project-info ;;
"dl") get-bib-and-download-paper "$2" ;; # inside project
"bib") add-bib-citation-to-refs "$2" ;; # inside project
"download") download-paper "$2" "$3" ;; # outside project
"citation") fetch-bib-no-add "$2" ;; # outside project
"ls") list-project-files "$2" ;;
"anchor") save-to-local ;;
"unanchor") remove-from-local-prompt ;;
"showall") show-local-registry ;;
"rename") rename-stuff "$2" "$3" ;;
"lookup") pdfgrep-term-freq "$2" ;;
"relookup") pdfgrep-term-freq-again "$2" ;;
"update") update-project-info-file ;;
*) echolor yellow ":: Unrecognized command." ;;
esac