]> git.pld-linux.org Git - packages/feh.git/blob - feh-bash-completion
up to 3.10.2
[packages/feh.git] / feh-bash-completion
1 # bash completion for feh(1)                               -*- shell-script -*-
2
3 _comp_cmd_feh()
4 {
5     local cur prev words cword was_split comp_args
6     _comp_initialize -s -- "$@" || return
7
8     local noargopts='!(-*|*[foO|KCjeM@TSRHWEyJabgLD~^]*)'
9     # shellcheck disable=SC2254
10     case "$prev" in
11         --image-bg | -B)
12             _comp_compgen -- -W 'checks white black'
13             return
14             ;;
15         --filelist | --output | --output-only | --start-at | -${noargopts}[foO\|])
16             _comp_compgen_filedir
17             return
18             ;;
19         --caption-path | --fontpath | --output-dir | -${noargopts}[KCj])
20             _comp_compgen_filedir -d
21             return
22             ;;
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}'
27                 compopt -o nospace
28                 return
29             fi
30             local font_path
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 /
38                 fi
39             done
40             compopt -o nospace
41             return
42             ;;
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
49                     continue
50                 fi
51                 _comp_compgen -a -- -W "$theme_name"
52             done <"$conf_path"
53             return
54             ;;
55         --sort | -${noargopts}S)
56             _comp_compgen -- -W 'name filename mtime width height pixels size
57                 format'
58             return
59             ;;
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}'
64             compopt -o nospace
65             return
66             ;;
67         --zoom)
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}'
72                 compopt -o nospace
73             fi
74             return
75             ;;
76         --alpha | -${noargopts}a)
77             _comp_compgen -- -W '{0..255}'
78             return
79             ;;
80         --bg | -${noargopts}b)
81             _comp_compgen_filedir
82             _comp_compgen -a -- -W 'trans'
83             return
84             ;;
85         --geometry | --max-dimension | --min-dimension | -${noargopts}g)
86             # expect string like 640x480
87             if [[ $cur && $cur != *x* ]]; then
88                 COMPREPLY=(x)
89             fi
90             _comp_compgen -aR -- -W "{0..9}"
91             compopt -o nospace
92             return
93             ;;
94         --customlist | --index-info | --info | --slideshow-delay | --thumb-title | \
95             --title | -${noargopts}[LD~^])
96             # argument required but no completions available
97             return
98             ;;
99     esac
100
101     [[ $was_split ]] && return
102
103     if [[ $cur == -* ]]; then
104         # Some versions of feh just output "See 'man feh'" for --help :(
105         _comp_compgen_help
106         if [[ ${COMPREPLY-} ]]; then
107             [[ $COMPREPLY == *= ]] && compopt -o nospace
108             return
109         fi
110     fi
111
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'
115 } &&
116     complete -F _comp_cmd_feh feh
117
118 # ex: filetype=sh
This page took 0.135465 seconds and 4 git commands to generate.