X-Git-Url: https://git.madduck.net/etc/zsh.git/blobdiff_plain/a0644f815aaeffc9ffa5c3411f2c3c3d70914586..bc7e3da7bae02125450f495af9ac03b6675aaf41:/.zsh/zshrc/30_aliases?ds=sidebyside diff --git a/.zsh/zshrc/30_aliases b/.zsh/zshrc/30_aliases index 7acf460..d806681 100644 --- a/.zsh/zshrc/30_aliases +++ b/.zsh/zshrc/30_aliases @@ -211,6 +211,15 @@ pdfextract() { local o=$2 shift 2 pdftk "$i" cat "${@:-1-end}" output "${o%.pdf}.pdf" + if [ -n "$1" ]; then + local tmpfile + tmpfile=$(tempfile -p pdftk -s .pdf) + cleanup() { rm -f $tmpfile; trap - EXIT; } + trap cleanup EXIT + pdftk "$i" cat "1-end~${(j:~:)@}" output $tmpfile + mv $tmpfile "$i" + cleanup + fi } compdef _files pdfextract