1 # bash completion for feh(1) -*- shell-script -*-
5 local cur prev words cword was_split comp_args
6 _comp_initialize -s -- "$@" || return
8 local noargopts='!(-*|*[foO|KCjeM@TSRHWEyJabgLD~^]*)'
9 # shellcheck disable=SC2254
12 _comp_compgen -- -W 'checks white black'
15 --filelist | --output | --output-only | --start-at | -${noargopts}[foO\|])
19 --caption-path | --fontpath | --output-dir | -${noargopts}[KCj])
20 _comp_compgen_filedir -d
23 --font | --menu-font | --title-font | -${noargopts}[eM@])
24 # expect string like "dejavu.ttf/12"
25 if [[ $cur == */* ]]; then # expect integer value
26 _comp_compgen -R -- -P "$cur" -W '{0..9}'
31 # font_path="$(imlib2-config --prefix 2>/dev/null)/share/imlib2/data/fonts"
32 # _comp_compgen -C "$font_path" -- -f -X "!*.@([tT][tT][fF])" -S /
33 for ((i = ${#words[@]} - 1; i > 0; i--)); do
34 if [[ ${words[i]} == -@(C|-fontpath) ]]; then
35 font_path="${words[i + 1]}"
36 _comp_compgen -aC "$font_path" -- \
37 -f -X "!*.@([tT][tT][fF])" -S /
43 --theme | -${noargopts}T)
44 local conf_path=~/.config/feh/themes
45 local theme_name theme_opts
46 [[ -r $conf_path ]] || return
47 while read -r theme_name theme_opts; do
48 if [[ $theme_name == '#'* || $theme_name == "" ]]; then
51 _comp_compgen -a -- -W "$theme_name"
55 --sort | -${noargopts}S)
56 _comp_compgen -- -W 'name filename mtime width height pixels size
60 --reload | --limit-height | --limit-width | --thumb-height | --thumb-width | \
61 --thumb-redraw | --magick-timeout | -${noargopts}[RHWEyJ])
62 # expect integer value
63 _comp_compgen -aR -- -W '{0..9}'
68 # expect integer value or "max", "fill"
69 _comp_compgen -- -W 'max fill'
70 if [[ ! $cur || ! ${COMPREPLY-} ]]; then
71 _comp_compgen -aR -- -W '{0..9}'
76 --alpha | -${noargopts}a)
77 _comp_compgen -- -W '{0..255}'
80 --bg | -${noargopts}b)
82 _comp_compgen -a -- -W 'trans'
85 --geometry | --max-dimension | --min-dimension | -${noargopts}g)
86 # expect string like 640x480
87 if [[ $cur && $cur != *x* ]]; then
90 _comp_compgen -aR -- -W "{0..9}"
94 --customlist | --index-info | --info | --slideshow-delay | --thumb-title | \
95 --title | -${noargopts}[LD~^])
96 # argument required but no completions available
101 [[ $was_split ]] && return
103 if [[ $cur == -* ]]; then
104 # Some versions of feh just output "See 'man feh'" for --help :(
106 if [[ ${COMPREPLY-} ]]; then
107 [[ $COMPREPLY == *= ]] && compopt -o nospace
112 # FIXME: It is hard to determine correct supported extensions.
113 # feh can handle any format that imagemagick can plus some others
114 _comp_compgen_filedir 'xpm|tif?(f)|png|p[npgba]m|iff|?(i)lbm|jp?(e)g|jfi?(f)|gif|bmp|arg?(b)|tga|xcf|ani|ico|?(e)ps|pdf|dvi|txt|svg?(z)|cdr|[ot]tf|ff?(.gz|.bz2)|webp'
116 complete -F _comp_cmd_feh feh