mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-10 20:33:46 +01:00
0b9571e4c1
If bash_completion wasn't installed, _filedir wouldn't be defined which led to all filename-based completions to error out. Specifically autocompletion would fail when a filename was expected and when bash_completion wasn't installed. Now we fall back to compgen -f if _filedir fails. According to _filedir's comments, compgen doesn't handle files with spaces well, but it is still better to complete most files than none.
29 lines
635 B
Bash
29 lines
635 B
Bash
#!/bin/bash
|
|
_zathura() {
|
|
_init_completion 2>/dev/null || true
|
|
|
|
local EXTS=""
|
|
for PLUGIN in @PLUGINDIR@/lib*.so; do
|
|
case ${PLUGIN##*/} in
|
|
libpdf-poppler.so)
|
|
EXTS="$EXTS|pdf|PDF"
|
|
;;
|
|
libpdf-mupdf.so)
|
|
EXTS="$EXTS|pdf|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#|}" 2>/dev/null || COMPREPLY=($(shopt -s extglob; compgen -f -X "!*.@($EXTS)"))
|
|
}
|
|
complete -F _zathura zathura
|