X-Git-Url: https://git.madduck.net/etc/zsh.git/blobdiff_plain/ba79da8b82d0d955a1ae93b8d38eaa49468ca346..8381ec42c81bc4e252e4310dc78a4fea5880fddb:/.zsh/zshrc/30_aliases?ds=inline 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