summaryrefslogtreecommitdiffstats
path: root/.scripts
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2019-01-17 12:18:41 -0500
committerLuke Smith <luke@lukesmith.xyz>2019-01-17 12:18:41 -0500
commit62bec93648b7966e1e3862c7fd5a30ec7dd4a7df (patch)
treec4ccb6076753d7c9e49435b6b05163f82b74aabf /.scripts
parent00d5e97f32147d6ef30c07cf00b00bc1f2538056 (diff)
downloadeibhear-62bec93648b7966e1e3862c7fd5a30ec7dd4a7df.tar.gz
eibhear-62bec93648b7966e1e3862c7fd5a30ec7dd4a7df.tar.zst
eibhear-62bec93648b7966e1e3862c7fd5a30ec7dd4a7df.zip
compiler simplification
Diffstat (limited to '.scripts')
-rwxr-xr-x.scripts/tools/compiler25
1 files changed, 6 insertions, 19 deletions
diff --git a/.scripts/tools/compiler b/.scripts/tools/compiler
index cf628aa..7d3bf1d 100755
--- a/.scripts/tools/compiler
+++ b/.scripts/tools/compiler
@@ -1,21 +1,14 @@
#!/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
+# Compiles .tex. groff (.mom, .ms), .rmd, .md.
+# Opens .sent files as sent presentations.
+# Runs scripts based on extention or shebang
file=$(readlink -f "$1")
dir=$(dirname "$file")
base="${file%.*}"
-shebang=$(sed -n 1p "$file")
cd "$dir" || exit
@@ -29,22 +22,16 @@ textype() { \
$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 ;;
+ *config.h) sudo make install ;;
*\.c) cc "$file" -o "$base" && "$base" ;;
*\.py) python "$file" ;;
*\.go) go run "$file" ;;
- *) shebangtest ;;
+ *\.sent) setsid sent "$file" 2>/dev/null & ;;
+ *) sed 1q "$file" | grep "^#!/" | sed "s/^#!//" | xargs -r -I % "$file" ;;
esac