summaryrefslogtreecommitdiff
path: root/.i3/scripts/compiler
diff options
context:
space:
mode:
authorVito Graffagnino <vito@graffagnino.xyz>2020-09-08 18:10:49 +0100
committerVito Graffagnino <vito@graffagnino.xyz>2020-09-08 18:10:49 +0100
commit3b0142cedcde39e4c2097ecd916a870a3ced5ec6 (patch)
tree2116c49a845dfc0945778f2aa3e2118d72be428b /.i3/scripts/compiler
parent8cc927e930d5b6aafe3e9862a61e81705479a1b4 (diff)
Added the relevent parts of the .config directory. Alss add ssh config
Diffstat (limited to '.i3/scripts/compiler')
-rwxr-xr-x.i3/scripts/compiler50
1 files changed, 50 insertions, 0 deletions
diff --git a/.i3/scripts/compiler b/.i3/scripts/compiler
new file mode 100755
index 0000000..cf628aa
--- /dev/null
+++ b/.i3/scripts/compiler
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+# This script will compile or run another finishing operation on a document. I
+# have this script run via vim.
+#
+# tex files: Compiles to pdf, including bibliography if necessary
+# md files: Compiles to pdf via pandoc
+# rmd files: Compiles via R Markdown
+# c files: Compiles via whatever compiler is set to cc. Usually gcc.
+# py files: runs via python command
+# go files: compiles and runs with "go run"
+# config.h files: (For suckless utils) recompiles and installs program.
+# all others: run `sent` to show a presentation
+
+file=$(readlink -f "$1")
+dir=$(dirname "$file")
+base="${file%.*}"
+shebang=$(sed -n 1p "$file")
+
+cd "$dir" || exit
+
+textype() { \
+ command="pdflatex"
+ ( sed 5q "$file" | grep -i -q 'xelatex' ) && command="xelatex"
+ $command --output-directory="$dir" "$base" &&
+ grep -i addbibresource "$file" >/dev/null &&
+ biber --input-directory "$dir" "$base" &&
+ $command --output-directory="$dir" "$base" &&
+ $command --output-directory="$dir" "$base"
+ }
+
+shebangtest() {
+ case "$shebang" in
+ \#\!*) "$file" ;;
+ *) sent "$file" 2>/dev/null & ;;
+ esac
+}
+
+case "$file" in
+ *\.ms) refer -PS -e "$file" | groff -me -ms -kejpt -T pdf > "$base".pdf ;;
+ *\.mom) refer -PS -e "$file" | groff -mom -kejpt -T pdf > "$base".pdf ;;
+ *\.rmd) echo "require(rmarkdown); render('$file')" | R -q --vanilla ;;
+ *\.tex) textype "$file" ;;
+ *\.md) pandoc "$file" --pdf-engine=xelatex -o "$base".pdf ;;
+ *config.h) make && sudo make install ;;
+ *\.c) cc "$file" -o "$base" && "$base" ;;
+ *\.py) python "$file" ;;
+ *\.go) go run "$file" ;;
+ *) shebangtest ;;
+esac