dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 081c34b404b25a249be848746b6ca6438343a00b
parent b2450cb5b6144a163afa560e521944580710089f
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Fri, 12 Jun 2020 16:24:02 +0200

Allow both continuous compilation and opening with more file formats

Diffstat:
M.local/bin/compile | 34++++++++++++++++++++++++++--------
1 file changed, 26 insertions(+), 8 deletions(-)

diff --git a/.local/bin/compile b/.local/bin/compile @@ -21,7 +21,7 @@ die() { run_compile() { base="${2%.*}" if [ "$continuous" = 1 ]; then - echo "$2" | entr -s "$1" + printf '%s\n' "$2" | entr -s "$1" else eval $1 fi @@ -40,18 +40,36 @@ handle_target() { latexmk -pvc -pdf -f "$1" else latexmk -pdf $preview -f "$1" - fi;; + fi + ;; *\.gp) - run_compile "gnuplot '$1'" "$1";; + run_compile "gnuplot '$1'" "$1" + ;; *\.c) - run_compile "cc -std=c99 -pedantic -Wall -O2 -g '$1' -o '${1%%.*}'" "$1";; + if [ "$open" = 1 ]; then + run_compile "cc $CFLAGS $LDFLAGS -std=c99 -pedantic -Wall -O2 -g '$1' -o '${1%.*}' && ./${1%.*}" "$1" + else + run_compile "cc $CFLAGS $LDFLAGS -std=c99 -pedantic -Wall -O2 -g '$1' -o '${1%.*}'" "$1" + fi + ;; *\.[0-9]) - run_compile "refer -PS -e '$1' | groff -mandoc -T pdf > '$(basename "${base}").pdf'" "$1";; + out="$(basename "${base}").pdf" + if [ "$open" = 1 ]; then + run_compile "refer -PS -e '$1' | groff -mandoc -T pdf > '$out' && xdg-open '$out'" "$1" + else + run_compile "refer -PS -e '$1' | groff -mandoc -T pdf > '$out'" "$1" + fi + ;; *\.mom) - run_compile "pdfmom '$1' > '$(basename "${base}").pdf'" "$1";; + out="$(basename "${base}").pdf" + if [ "$open" = 1 ]; then + run_compile "pdfmom '$1' > '$out' && xdg-open '$out'" "$1" + else + run_compile "pdfmom '$1' > '$out'" "$1" + fi + ;; *) - (>2 printf "File type %s not supported\n" $extension) - exit 1;; + die "File type $extension not supported\n";; esac else die "cannot open $1"