From 753ca0f315821c19d304a09873136e5119a6be50 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 22 May 2018 14:55:34 +0200 Subject: [PATCH] Add zsh completion --- data/meson.build | 6 +++++ data/zsh-completion.in | 52 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 data/zsh-completion.in diff --git a/data/meson.build b/data/meson.build index ec5fd86..55cbe39 100644 --- a/data/meson.build +++ b/data/meson.build @@ -52,5 +52,11 @@ bash_completion = configure_file( output: 'zathura', configuration: conf_data ) +zsh_completion = configure_file( + input: 'zsh-completion.in', + output: '_zathura', + configuration: conf_data +) install_data(bash_completion, install_dir: join_paths(datadir, 'bash-completion', 'completions')) +install_data(zsh_completion, install_dir: join_paths(datadir, 'zsh', 'vendor-completions')) diff --git a/data/zsh-completion.in b/data/zsh-completion.in new file mode 100644 index 0000000..bdb8471 --- /dev/null +++ b/data/zsh-completion.in @@ -0,0 +1,52 @@ +#compdef zathura + +local -a all_opts +all_opts=( + '(-c --config-dir=DIR)'{-c,--config-dir}'[Path to config directory]:config directory:_files -/' + '(-d --data-dir=DIR)'{-d,--data-dir}'[Path to data directory]:data directory:_files -/' + '--cache-dir=DIR[Path to cache directory]:cache directory:_files -/' + '(-p --plugins-dir=DIR)'{-p,--plugins-dir}'[Path to plugins directory]:plugins directory:_files -/' + '(-e --reparent=XID)'{-e,--reparent}'[Reparents to window specified by XID (X11)]:xid' + '(-w --password=password)'{-w,--password}'[Document password]:password' + '(-P --page=page)'{-p,--page}'[Page number to go to]:page number' + '(-l --log-level=level)'{-l,--log-level}'[Log level]:level:(error warning info debug)' + '(-x --snyctex-editor-command=cmd)'{-x,--synxtec-editor-command}'[Synctex editor (forwarded to the synctex command)]:command' + '--synctex-forward=position[Move to given synctex position]:position' + '--synctex-pid=pid[Highlight position in given process]:pid' + '--mode=mode[Start in a non-default mode]:mode:(presentation fullscreen)' + '--fork[Fork into the background]' + '-h --help[Show help message]' + '-V --version[Print version information]' + '*:file:->files' +) + +local context state state_descr line +typeset -A opt_args +_arguments -S "$all_opts[@]" && return 0 + +local exts +for PLUGIN in @PLUGINDIR@/lib*.so; do + case ${PLUGIN##*/} in + libpdf-poppler.so) + exts="$exts|pdf" + ;; + libpdf-mupdf.so) + exts="$exts|pdf|epub|oxps" + ;; + libps.so) + exts="$exts|ps|eps|epsi|epsf" + ;; + libdjvu.so) + exts="$exts|djvu|djv" + ;; + libcb.so) + exts="$exts|cb7|cbr|cbz|cbt|rar|zip|7z|tar" + ;; + esac +done + +case $state in + (files) + _files -g "*.($exts)" + ;; +esac