From: Simon Ruderich Date: Tue, 24 Jan 2012 17:06:38 +0000 (+0100) Subject: zsh/rc: Add pdf command. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=ad26dac43cbd7b8acb92d4f5ec7431d8022703ac;p=config%2Fdotfiles.git zsh/rc: Add pdf command. Chooses the "best" PDF viewer available. --- diff --git a/zsh/rc b/zsh/rc index ccc8ea7..85139dc 100644 --- a/zsh/rc +++ b/zsh/rc @@ -644,11 +644,22 @@ tree() { command tree -C "$@" | less } -# Automatically disown. -xpdf() { - command xpdf "$@" & - disown %command -} +# Choose the "best" PDF viewer available: zathura, then xpdf. Also setup +# completion for `pdf`. +if (( $+commands[zathura] )); then + pdf() { + command zathura "$@" 2>/dev/null & + disown %command + } + # No completion for zathura yet. + compdef _xpdf pdf +elif (( $+commands[xpdf] )); then + pdf() { + command xpdf "$@" 2>/dev/null & + disown %command + } + compdef _xpdf pdf +fi # GHCI doesn't use readline, force it if rlwrap is available. (( $+commands[rlwrap] )) && ghci() {