summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSalman Abedin <salman104alvi@gmail.com>2020-06-07 05:17:35 +0600
committerGitHub <noreply@github.com>2020-06-06 19:17:35 -0400
commita275422d47442e91c0748c5677551d852d6e4f21 (patch)
treea58256fe168e7e8b47dc349da4007354d765fefc
parent7572627e85b52e1da5156b16432fcab64e7b4eb3 (diff)
downloadeibhear-a275422d47442e91c0748c5677551d852d6e4f21.tar.gz
eibhear-a275422d47442e91c0748c5677551d852d6e4f21.tar.zst
eibhear-a275422d47442e91c0748c5677551d852d6e4f21.zip
Much cleaner compiler script (#692)
Co-authored-by: Salman Abedin <salmanabedin@zohomail.com>
-rwxr-xr-x.local/bin/compiler29
1 files changed, 15 insertions, 14 deletions
diff --git a/.local/bin/compiler b/.local/bin/compiler
index f28ffe1..4f1ad50 100755
--- a/.local/bin/compiler
+++ b/.local/bin/compiler
@@ -12,6 +12,7 @@
file=$(readlink -f "$1")
dir=${file%/*}
base="${file%.*}"
+ext="${file##*.}"
cd "$dir" || exit
@@ -25,25 +26,25 @@ textype() { \
$command --output-directory="$dir" "$base"
}
-case "$file" in
- *\.ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf > "$base".pdf ;;
- *\.mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf > "$base".pdf ;;
- *\.[0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;;
- *\.[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
- *\.tex) textype "$file" ;;
- *\.md) if command -v lowdown >/dev/null; then
+case "$ext" in
+ ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf > "$base".pdf ;;
+ mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf > "$base".pdf ;;
+ [0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;;
+ [rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
+ tex) textype "$file" ;;
+ md) if command -v lowdown >/dev/null; then
lowdown -d nointem -e super "$file" -Tms | groff -mpdfmark -ms -kept > "$base".pdf
elif command -v groffdown >/dev/null; then
groffdown -i "$file" | groff > "$base.pdf"
else
pandoc "$file" --pdf-engine=xelatex -o "$base".pdf
fi ; ;;
- *config.h) sudo make install ;;
- *\.c) cc "$file" -o "$base" && "$base" ;;
- *\.py) python "$file" ;;
- *\.m) octave "$file" ;;
- *\.scad) openscad -o "$base".stl "$file" ;;
- *\.go) go run "$file" ;;
- *\.sent) setsid -f sent "$file" 2>/dev/null ;;
+ h) sudo make install ;;
+ c) cc "$file" -o "$base" && "$base" ;;
+ py) python "$file" ;;
+ m) octave "$file" ;;
+ scad) openscad -o "$base".stl "$file" ;;
+ go) go run "$file" ;;
+ sent) setsid -f sent "$file" 2>/dev/null ;;
*) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
esac