]> ruderich.org/simon Gitweb - config/dotfiles.git/commitdiff
zsh/rc: Add pdf command.
authorSimon Ruderich <simon@ruderich.org>
Tue, 24 Jan 2012 17:06:38 +0000 (18:06 +0100)
committerSimon Ruderich <simon@ruderich.org>
Tue, 24 Jan 2012 17:06:38 +0000 (18:06 +0100)
Chooses the "best" PDF viewer available.

zsh/rc

diff --git a/zsh/rc b/zsh/rc
index ccc8ea7638fcb3f85cca76e3fbe2e77f724687a9..85139dcdd305b6745818f56b8e600b2cb6c7c9c9 100644 (file)
--- 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() {