diff --git a/data/bash-completion.in b/data/bash-completion.in new file mode 100644 index 0000000..34bd4a4 --- /dev/null +++ b/data/bash-completion.in @@ -0,0 +1,27 @@ +_zathura() { + _init_completion || return + + 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 + + _filedir "${EXTS#|}" +} +complete -F _zathura zathura diff --git a/data/meson.build b/data/meson.build index a1d2cff..ec5fd86 100644 --- a/data/meson.build +++ b/data/meson.build @@ -44,3 +44,13 @@ if appstream_util.found() args: ['validate-relax', appdata.full_path()] ) endif + +conf_data = configuration_data() +conf_data.set('PLUGINDIR', join_paths(prefix, plugindir)) +bash_completion = configure_file( + input: 'bash-completion.in', + output: 'zathura', + configuration: conf_data +) + +install_data(bash_completion, install_dir: join_paths(datadir, 'bash-completion', 'completions'))