tdf#118711 writerfilter: don't hardcode default page description
[LibreOffice.git] / bin / bash-completion.in
blob77087c59316c25003199480ea10e5c5a37fe39f5
1 # Programmable bash_completion file for the main office applications
2 # It is based on /etc/profile.d/complete.bash from SUSE Linux 10.1
4 _def=; _dir=; _file=; _nosp=
5 if complete -o default _nullcommand &> /dev/null ; then
6     _def="-o default"
7     _dir="-o dirnames"
8     _file="-o filenames"
9 fi
10 _minusdd="-d ${_dir}"
11 _minusdf="-d ${_file}"
12 if complete -o nospace _nullcommand &> /dev/null ; then
13     _nosp="-o nospace"
14     _minusdd="${_nosp} ${_dir}"
15     _minusdf="${_nosp} ${_dir}"
17 complete -r _nullcommand &> /dev/null
19 # General expanding shell function
20 @OFFICE_SHELL_FUNCTION@ ()
22     # bash `complete' is broken because you can not combine
23     # -d, -f, and -X pattern without missing directories.
24     local c=${COMP_WORDS[COMP_CWORD]}
25     local a="${COMP_LINE}"
26     local e s g=0 cd dc t=""
27     local IFS
29     shopt -q extglob && g=1
30     test $g -eq 0 && shopt -s extglob
31     # Don't be fooled by the bash parser if extglob is off by default
32     cd='*-?(c)d*'
33     dc='*-d?(c)*'
35     case "${1##*/}" in
36 @BASH_COMPLETION_SUFFIXES_CHECKS@
37     *)                  e='!*'
38     esac
40     case "$(complete -p ${1##*/} 2> /dev/null)" in
41         *-d*)   ;;
42         *) s="-S/"
43     esac
45     IFS='
47     case "$c" in
48     \$\(*\))       eval COMPREPLY=\(${c}\) ;;
49     \$\(*)              COMPREPLY=($(compgen -c -P '$(' -S ')'  -- ${c#??}))    ;;
50     \`*\`)         eval COMPREPLY=\(${c}\) ;;
51     \`*)                COMPREPLY=($(compgen -c -P '\`' -S '\`' -- ${c#?}))     ;;
52     \$\{*\})       eval COMPREPLY=\(${c}\) ;;
53     \$\{*)              COMPREPLY=($(compgen -v -P '${' -S '}'  -- ${c#??}))    ;;
54     \$*)                COMPREPLY=($(compgen -v -P '$'          -- ${c#?}))     ;;
55     \~*/*)              COMPREPLY=($(compgen -f -X "$e"         -- ${c}))       ;;
56     \~*)                COMPREPLY=($(compgen -u ${s}            -- ${c}))       ;;
57     *@*)                COMPREPLY=($(compgen -A hostname -P '@' -S ':' -- ${c#*@})) ;;
58     *[*?[]*)            COMPREPLY=($(compgen -G "${c}"))                        ;;
59     *[?*+\!@]\(*\)*)
60         if test $g -eq 0 ; then
61                         COMPREPLY=($(compgen -f -X "$e" -- $c))
62                         test $g -eq 0 && shopt -u extglob
63                         return
64         fi
65                         COMPREPLY=($(compgen -G "${c}"))                        ;;
66     *)
67         if test "$c" = ".." ; then
68                         COMPREPLY=($(compgen -d -X "$e" -S / ${_nosp} -- $c))
69         else
70                         for s in $(compgen -f -X "$e" -- $c) ; do
71                             if test -d $s ; then
72                                 COMPREPLY=(${COMPREPLY[@]} $(compgen -f -X "$e" -S / -- $s))
73                             elif test -z "$t" ; then
74                                 COMPREPLY=(${COMPREPLY[@]} $s)
75                             else
76                                 case "$(file -b $s 2> /dev/null)" in
77                                 $t) COMPREPLY=(${COMPREPLY[@]} $s)              ;;
78                                 esac
79                             fi
80                         done
81         fi                                                                      ;;
82     esac
83     test $g -eq 0 && shopt -u extglob
87 complete -d -X '.[^./]*' -F @OFFICE_SHELL_FUNCTION@ ${_file} \
88 @BASH_COMPLETION_OOO_APPS@
90 unset _def _dir _file _nosp _minusdd _minusdf