1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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'
|