updates :D
This commit is contained in:
parent
fa97251839
commit
fb91fa7348
@ -2,58 +2,51 @@
|
|||||||
|
|
||||||
# This script will compile or run another finishing operation on a document. I
|
# This script will compile or run another finishing operation on a document. I
|
||||||
# have this script run via vim.
|
# have this script run via vim.
|
||||||
#
|
|
||||||
# Compiles .tex. groff (.mom, .ms), .rmd, .md, .org. Opens .sent files as sent
|
# Compiles .tex. groff (.mom, .ms), .rmd, .md, .org. Opens .sent files as sent
|
||||||
# presentations. Runs scripts based on extension or shebang.
|
# presentations. Runs scripts based on extension or shebang.
|
||||||
#
|
|
||||||
# Note that .tex files which you wish to compile with XeLaTeX should have the
|
# Note that .tex files which you wish to compile with XeLaTeX should have the
|
||||||
# string "xelatex" somewhere in a comment/command in the first 5 lines.
|
# string "xelatex" somewhere in a comment/command in the first 5 lines.
|
||||||
|
|
||||||
file=$(readlink -f "$1")
|
file="${1}"
|
||||||
|
ext="${file##*.}"
|
||||||
dir=${file%/*}
|
dir=${file%/*}
|
||||||
base="${file%.*}"
|
base="${file%.*}"
|
||||||
ext="${file##*.}"
|
|
||||||
|
|
||||||
cd "$dir" || exit 1
|
cd "${dir}" || exit "1"
|
||||||
|
|
||||||
textype() { \
|
case "${ext}" in
|
||||||
textarget="$(getcomproot "$file" || echo "$file")"
|
[0-9]) preconv "${file}" | refer -PS -e | groff -mandoc -T pdf > "${base}.pdf" ;;
|
||||||
echo "$textarget"
|
mom|ms) preconv "${file}" | refer -PS -e | groff -T pdf -m"${ext}" > "${base}.pdf" ;;
|
||||||
command="pdflatex"
|
c) cc "${file}" -o "${base}" && "./${base}" ;;
|
||||||
( head -n5 "$textarget" | grep -qi 'xelatex' ) && command="xelatex"
|
cpp) g++ "${file}" -o "${base}" && "./${base}" ;;
|
||||||
$command --output-directory="${textarget%/*}" "${textarget%.*}"
|
cs) mcs "${file}" && mono "${base}.exe" ;;
|
||||||
grep -qi addbibresource "$textarget" &&
|
go) go run "${file}" ;;
|
||||||
biber --input-directory "${textarget%/*}" "${textarget%.*}" &&
|
|
||||||
$command --output-directory="${textarget%/*}" "${textarget%.*}" &&
|
|
||||||
$command --output-directory="${textarget%/*}" "${textarget%.*}"
|
|
||||||
}
|
|
||||||
|
|
||||||
case "$ext" in
|
|
||||||
# Try to keep these cases in alphabetical order.
|
|
||||||
[0-9]) preconv "$file" | refer -PS -e | groff -mandoc -T pdf > "$base".pdf ;;
|
|
||||||
c) cc "$file" -o "$base" && "$base" ;;
|
|
||||||
cpp) g++ "$file" -o "$base" && "$base" ;;
|
|
||||||
cs) mcs "$file" && mono "$base".exe ;;
|
|
||||||
go) go run "$file" ;;
|
|
||||||
h) sudo make install ;;
|
h) sudo make install ;;
|
||||||
java) javac -d classes "$file" && java -cp classes "${1%.*}" ;;
|
java) javac -d classes "${file}" && java -cp classes "${base}" ;;
|
||||||
m) octave "$file" ;;
|
m) octave "${file}" ;;
|
||||||
md) if [ -x "$(command -v lowdown)" ]; then
|
md) [ -x "$(command -v lowdown)" ] && \
|
||||||
lowdown --parse-no-intraemph "$file" -Tms | groff -mpdfmark -ms -kept -T pdf > "$base".pdf
|
lowdown --parse-no-intraemph "${file}" -Tms | groff -mpdfmark -ms -kept -T pdf > "${base}.pdf" || \
|
||||||
elif [ -x "$(command -v groffdown)" ]; then
|
[ -x "$(command -v groffdown)" ] && \
|
||||||
groffdown -i "$file" | groff -T pdf > "$base".pdf
|
groffdown -i "${file}" | groff -T pdf > "${base}.pdf" || \
|
||||||
else
|
pandoc -t ms --highlight-style="kate" -s -o "${base}.pdf" "${file}" ;;
|
||||||
pandoc -t ms --highlight-style=kate -s -o "$base".pdf "$file"
|
org) emacs "${file}" --batch -u "${USER}" -f org-latex-export-to-pdf ;;
|
||||||
fi ; ;;
|
py) python "${file}" ;;
|
||||||
mom) preconv "$file" | refer -PS -e | groff -mom -kept -T pdf > "$base".pdf ;;
|
[rR]md) Rscript -e "rmarkdown::render('${file}', quiet=TRUE)" ;;
|
||||||
ms) preconv "$file" | refer -PS -e | groff -me -ms -kept -T pdf > "$base".pdf ;;
|
|
||||||
org) emacs "$file" --batch -u "$USER" -f org-latex-export-to-pdf ;;
|
|
||||||
py) python "$file" ;;
|
|
||||||
[rR]md) Rscript -e "rmarkdown::render('$file', quiet=TRUE)" ;;
|
|
||||||
rs) cargo build ;;
|
rs) cargo build ;;
|
||||||
sass) sassc -a "$file" "$base".css ;;
|
sass) sassc -a "${file}" "${base}.css" ;;
|
||||||
scad) openscad -o "$base".stl "$file" ;;
|
scad) openscad -o "${base}.stl" "${file}" ;;
|
||||||
sent) setsid -f sent "$file" 2>/dev/null ;;
|
sent) setsid -f sent "${file}" 2> "/dev/null" ;;
|
||||||
tex) textype "$file" ;;
|
tex)
|
||||||
*) sed -n '/^#!/s/^#!//p; q' "$file" | xargs -r -I % "$file" ;;
|
textarget="$(getcomproot "${file}" || echo "${file}")"
|
||||||
|
command="pdflatex"
|
||||||
|
head -n5 "${textarget}" | grep -qi "xelatex" && command="xelatex"
|
||||||
|
${command} --output-directory="${textarget%/*}" "${textarget%.*}" &&
|
||||||
|
grep -qi addbibresource "${textarget}" &&
|
||||||
|
biber --input-directory "${textarget%/*}" "${textarget%.*}" &&
|
||||||
|
${command} --output-directory="${textarget%/*}" "${textarget%.*}" &&
|
||||||
|
${command} --output-directory="${textarget%/*}" "${textarget%.*}"
|
||||||
|
;;
|
||||||
|
*) sed -n '/^#!/s/^#!//p; q' "${file}" | xargs -r -I % "${file}" ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -32,7 +32,7 @@ twoscreen() { # If multi-monitor is selected and there are two screens.
|
|||||||
else
|
else
|
||||||
|
|
||||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
||||||
secondary=$(echo "$screens" | grep -v "$primary")
|
secondary=$(echo "$screens" | grep -v ^"$primary"$)
|
||||||
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
|
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
|
||||||
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
|
xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
|
||||||
fi
|
fi
|
||||||
@ -40,9 +40,9 @@ twoscreen() { # If multi-monitor is selected and there are two screens.
|
|||||||
|
|
||||||
morescreen() { # If multi-monitor is selected and there are more than two screens.
|
morescreen() { # If multi-monitor is selected and there are more than two screens.
|
||||||
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
|
||||||
secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:")
|
secondary=$(echo "$screens" | grep -v ^"$primary"$ | dmenu -i -p "Select secondary display:")
|
||||||
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
|
direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
|
||||||
tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:")
|
tertiary=$(echo "$screens" | grep -v ^"$primary"$ | grep -v ^"$secondary"$ | dmenu -i -p "Select third display:")
|
||||||
xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto
|
xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,9 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
# A helper script for LaTeX/groff files used by `compiler` and `opout`.
|
# A helper script for LaTeX/groff files used by `compiler` and `opout`.
|
||||||
# The user can add the root file of a larger project as a comment as below:
|
# The user can add the root file of a larger project as a comment as below:
|
||||||
# % root = mainfile.tex
|
# % root = mainfile.tex
|
||||||
# And the compiler script will run on that instead of the opened file.
|
# And the compiler script will run on that instead of the opened file.
|
||||||
|
|
||||||
texroot="$(grep -i "^.\+\s*root\s*=\s*\S\+" "$1")"
|
texroot="$(sed -n 's/^\s*%.*root\s*=\s*\(\S\+\).*/\1/p' "${1}")"
|
||||||
texroot="${texroot##*=}"
|
[ -f "${texroot}" ] && readlink -f "${texroot}" || exit "1"
|
||||||
texroot="${texroot//[\"\' ]}"
|
|
||||||
|
|
||||||
[ -f "$texroot" ] && readlink -f "$texroot" || exit 1
|
|
||||||
|
|||||||
@ -7,12 +7,14 @@
|
|||||||
# variables
|
# variables
|
||||||
output="$(date '+%y%m%d-%H%M-%S').png"
|
output="$(date '+%y%m%d-%H%M-%S').png"
|
||||||
xclip_cmd="xclip -sel clip -t image/png"
|
xclip_cmd="xclip -sel clip -t image/png"
|
||||||
|
ocr_cmd="xclip -sel clip"
|
||||||
|
|
||||||
case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)" | dmenu -l 6 -i -p "Screenshot which area?")" in
|
case "$(printf "a selected area\\ncurrent window\\nfull screen\\na selected area (copy)\\ncurrent window (copy)\\nfull screen (copy)\\nOCR a selected area (copy)" | dmenu -l 7 -i -p "Screenshot which area?")" in
|
||||||
"a selected area") maim -u -s pic-selected-"${output}" ;;
|
"a selected area") maim -u -s pic-selected-"${output}" ;;
|
||||||
"current window") maim -q -d 0.2 -i "$(xdotool getactivewindow)" pic-window-"${output}" ;;
|
"current window") maim -B -q -d 0.2 -i "$(xdotool getactivewindow)" pic-window-"${output}" ;;
|
||||||
"full screen") maim -q -d 0.2 pic-full-"${output}" ;;
|
"full screen") maim -q -d 0.2 pic-full-"${output}" ;;
|
||||||
"a selected area (copy)") maim -u -s | ${xclip_cmd} ;;
|
"a selected area (copy)") maim -u -s | ${xclip_cmd} ;;
|
||||||
"current window (copy)") maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${xclip_cmd} ;;
|
"current window (copy)") maim -q -d 0.2 -i "$(xdotool getactivewindow)" | ${xclip_cmd} ;;
|
||||||
"full screen (copy)") maim -q -d 0.2 | ${xclip_cmd} ;;
|
"full screen (copy)") maim -q -d 0.2 | ${xclip_cmd} ;;
|
||||||
|
"a selected area (OCR)") tmpfile=$(mktemp /tmp/ocr-XXXXXX.png) && maim -u -s > "$tmpfile" && tesseract "$tmpfile" - -l eng | ${ocr_cmd} && rm "$tmpfile" ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user