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
11 _minusdf="-d ${_file}"
12 if complete -o nospace _nullcommand &> /dev/null ; then
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=""
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
36 @BASH_COMPLETION_SUFFIXES_CHECKS@
40 case "$(complete -p ${1##*/} 2> /dev/null)" 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}")) ;;
60 if test $g -eq 0 ; then
61 COMPREPLY=($(compgen -f -X "$e" -- $c))
62 test $g -eq 0 && shopt -u extglob
65 COMPREPLY=($(compgen -G "${c}")) ;;
67 if test "$c" = ".." ; then
68 COMPREPLY=($(compgen -d -X "$e" -S / ${_nosp} -- $c))
70 for s in $(compgen -f -X "$e" -- $c) ; do
72 COMPREPLY=(${COMPREPLY[@]} $(compgen -f -X "$e" -S / -- $s))
73 elif test -z "$t" ; then
74 COMPREPLY=(${COMPREPLY[@]} $s)
76 case "$(file -b $s 2> /dev/null)" in
77 $t) COMPREPLY=(${COMPREPLY[@]} $s) ;;
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