Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Add completion for zathura.
- X-seq: zsh-workers 43001
- From: doron.behar@xxxxxxxxx
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Add completion for zathura.
- Date: Wed, 13 Jun 2018 19:31:52 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=eXTikUeDla+byVz0r0DTE0+HLwCgBva+V+lLiZLXCVo=; b=jpDW/pcxr1ul0Ys6InBZ5BDDCTCfUP6VsOstr2CX/bAER1IOAtcOA6sNLH8NPmZxCP ALaiKktl3sEQ1EOYtIvudbWgtAph4P+UCJyoPotx3PF8J0dkEoBtDWqPk5vLm8H2Wsru 7SwwqVzvgg5owPvRon2pyHr6uj3ke2n8r1TPPyUNKHfh3d3ae32eurGIrB8pfEXsg/nA YdipeZ9C8OINLHciNJcwj6L6dYM+A/FOSQP5UFpsX8YIWdfHEw+CXXv4sEXnq09u9xmd y2Q3C+4lnz2cB6RYE86546pNMD0n0DMwYsRANfQLxM3rMdYinIxA0Eu4VR+clBZDHWAE 7WyA==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
From: Doron Behar <doron.behar@xxxxxxxxx>
Make it aware of the plugins installed on the machine.
---
Completion/Unix/Type/_pspdf | 2 +-
Completion/X/Command/_zathura | 45 +++++++++++++++++++++++++++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
create mode 100644 Completion/X/Command/_zathura
diff --git a/Completion/Unix/Type/_pspdf b/Completion/Unix/Type/_pspdf
index 5bb8650b1..1df3f860c 100644
--- a/Completion/Unix/Type/_pspdf
+++ b/Completion/Unix/Type/_pspdf
@@ -1,4 +1,4 @@
-#compdef gsbj gsdj gsdj500 gslj gslp gsnd ps2ascii ghostview mgv pstoedit pstotgif zathura
+#compdef gsbj gsdj gsdj500 gslj gslp gsnd ps2ascii ghostview mgv pstoedit pstotgif
local expl ext
diff --git a/Completion/X/Command/_zathura b/Completion/X/Command/_zathura
new file mode 100644
index 000000000..9116d2471
--- /dev/null
+++ b/Completion/X/Command/_zathura
@@ -0,0 +1,45 @@
+#compdef zathura
+
+(( $+functions[_zathura_files] )) ||
+_zathura_files(){
+ local -a plugin_files
+ for plugins_dir in "${opt_args[-p]}" "${opt_args[--plugins-dir]}" "/usr/lib/zathura" "/usr/local/lib/zathura" "/lib/zathura"; do
+ plugin_files=(${plugins_dir}/*.so)
+ if [[ -z "${plugin_files}" ]]; then
+ break
+ fi
+ done
+ if [[ -z "${plugin_files}" ]]; then
+ _files -g "*.pdf(-.)"
+ return
+ fi
+ local -a supported_filetypes
+ for pf in "${plugin_files[@]}"; do
+ if [[ $pf =~ "mupdf" ]]; then
+ supported_filetypes+="pdf"
+ supported_filetypes+="epub"
+ supported_filetypes+="xps"
+ elif [[ $pf =~ "poppler" ]]; then
+ supported_filetypes+="pdf"
+ else
+ supported_filetypes+="${${pf%.so}#${plugins_dir}/lib}"
+ fi
+ done
+ _files -g "*.(${(j.|.)supported_filetypes})(-.)"
+}
+
+_arguments \
+ {-e,--reparent=}'[Reparents to window specified by xid]:xid:_x_window' \
+ {-c,--config-dir=}'[Path to the config directory]:path:{_files -/}' \
+ {-d,--data-dir=}'[Path to the data directory]:path:{_files -/}' \
+ {-p,--plugins-dir=}'[Path to the directory containing plugins]:path:{_files -/}' \
+ {-w,--password=}"[The document's password]:password: " \
+ {-P,--page=}'[Opens the document at the given page number]:number: ' \
+ {-l,--log-level=}'[Set log level]:level:(debug info warning error)' \
+ {-x,--synctex-editor-command=}'[Set the synctex editor command]:command:_cmdstring' \
+ '--synctex-forward=[Jump to the given position]:input: ' \
+ '--synctex-pid=[Instead of looking for an instance having the correct file opened, try only the instance with the given PID]:pid:_pids' \
+ '--fork[Fork into background]' \
+ '(- :)--version[Display version string and exit]' \
+ '(- :)--help[Display help and exit]' \
+ '*:file:_zathura_files'
--
2.17.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author