Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 1/1] Add completion for zathura.
- X-seq: zsh-workers 42957
- From: doron.behar@xxxxxxxxx
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 1/1] Add completion for zathura.
- Date: Fri, 8 Jun 2018 18:53:31 +0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=U+R071N53c7Q7Up655qzujl4eJcjrRomNk3OlciEUDM=; b=dX/D9AhqGM9fqnTefQ6EbEvSub8WpkwZGXfnxJy+5qcUAT4Friq+sDIazAvTRlXOTS rtoJeKsv8qp8oK6rQwm7FR0LMza1CqV6BSuVCyNyhCLqmfz3eXXnZxz2m+8A3hlLUPvp iAoZPPKgqPQ9sAc6P0368n6tNsZCFPnhc07KeSsXlxhE+bgmyJuuzvAtq1mh6DTcGf9f nlgZ6CuZnH7Tsaw+9pfQTYq1gdSVSulkaeKY3HCc5dgVNA39seGd3OWT05s+jHWkZSRJ Olg3xM9OB4yHZaY7lLLF1MiMzmn1XGrRG9DlvwCAgyUy1gxx8rzkA7XzqLxI8L64WpJq 3zBQ==
- In-reply-to: <20180608155331.2891-1-doron.behar@gmail.com>
- 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
- References: <20180608155331.2891-1-doron.behar@gmail.com>
From: Doron Behar <doron.behar@xxxxxxxxx>
Make it aware of the plugins installed on the machine.
Use 2 spaces instead of tabs.
Use +functions[] for all helpers.
Make main file completion consider plugins dir.
Improve portability and use safer, more resources efficient when
evaluating files regex.
Small improvements to options' descriptions.
---
Completion/X/Command/_zathura | 49 +++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 Completion/X/Command/_zathura
diff --git a/Completion/X/Command/_zathura b/Completion/X/Command/_zathura
new file mode 100644
index 000000000..29cec11f2
--- /dev/null
+++ b/Completion/X/Command/_zathura
@@ -0,0 +1,49 @@
+#compdef zathura
+
+(( $+functions[_zathura_files] )) ||
+_zathura_files(){
+ for plugins_dir in "${opt_args[-p]}" "${opt_args[--plugins-dir]}" "/usr/lib/zathura"; do
+ if ! [[ -z "${plugins_dir}" ]]; then
+ break
+ fi
+ done
+ local -a plugin_files=(${plugins_dir}/*.so)
+ if [[ -z "${plugin_files}" ]]; then
+ _message -r "no plugins found on plugins dir"
+ 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}}"
+ fi
+ done
+ local files_regex="*.{${supported_filetypes[1]},"
+ for (( i = 2 ; i < ${#supported_filetypes[*]}; i ++)); do
+ files_regex="${files_regex}""${supported_filetypes[$i]}"","
+ done
+ files_regex="${files_regex}""${supported_filetypes[-1]}""}"
+ _files -g "${files_regex}"
+}
+
+_arguments \
+ {-e,--reparent=}'[Reparents to window specified by xid]:XID: ' \
+ {-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:_command' \
+ '--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.0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author