From ad26dac43cbd7b8acb92d4f5ec7431d8022703ac Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 24 Jan 2012 18:06:38 +0100 Subject: [PATCH] zsh/rc: Add pdf command. Chooses the "best" PDF viewer available. --- zsh/rc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) 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() { -- 2.45.2