summaryrefslogtreecommitdiffstats
path: root/.scripts/tools/compiler
diff options
context:
space:
mode:
authorLuke Smith <luke@lukesmith.xyz>2019-02-02 13:10:43 -0500
committerGitHub <noreply@github.com>2019-02-02 13:10:43 -0500
commita37aba2078c083fecb9761e5dd6c740cf1414989 (patch)
tree3b9e126da9cf874285718c91702fb14501a3faf5 /.scripts/tools/compiler
parent18378660cae369465f520fb656c64b59dc0c5411 (diff)
parent1bffcd12c363064829682e16690430a118d962a4 (diff)
downloadeibhear-a37aba2078c083fecb9761e5dd6c740cf1414989.tar.gz
eibhear-a37aba2078c083fecb9761e5dd6c740cf1414989.tar.zst
eibhear-a37aba2078c083fecb9761e5dd6c740cf1414989.zip
Merge branch 'master' into dmenuumount
Diffstat (limited to '.scripts/tools/compiler')
-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