home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / etc / bash_completion.d / ooffice.sh < prev    next >
Encoding:
Text File  |  2006-08-01  |  3.7 KB  |  107 lines

  1. # Programmable bash_completion file for the main OpenOffice.org applications
  2. # It is based on /etc/profile.d/complete.bash from SUSE Linux 10.1
  3.  
  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}"
  16. fi
  17. complete -r _nullcommand &> /dev/null
  18.  
  19. # General OOo expanding shell function
  20. _ooexp_ ()
  21. {
  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
  28.  
  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)*'
  34.  
  35.     case "${1##*/}" in
  36.     oobase)        e='!*.+(odb)' ;;
  37.     oofromtemplate)        e='!*.+(stw|dot|vor|stc|xlt|sti|pot|std|stw)' ;;
  38.     oodraw)        e='!*.+(sxd|std|dxf|emf|eps|met|pct|sgf|sgv|sda|sdd|vor|svm|wmf|bmp|gif|jpg|jpeg|jfif|fif|jpe|pcd|pcx|pgm|png|ppm|psd|ras|tga|tif|tiff|xbm|xpm|odg|otg|odc|odi|sds)' ;;
  39.     oocalc)        e='!*.+(sxc|stc|dif|dbf|xls|xlw|xlt|rtf|sdc|vor|slk|txt|htm|html|wk1|wks|123|xml|ods|ots|csv)' ;;
  40.     oomath)        e='!*.+(sxm|smf|mml|odf)' ;;
  41.     ooweb)        e='!*.+(htm|html|stw|txt|vor|oth)' ;;
  42.     ooffice)        e='!*.+(sxd|std|dxf|emf|eps|met|pct|sgf|sgv|sda|sdd|vor|svm|wmf|bmp|gif|jpg|jpeg|jfif|fif|jpe|pcd|pcx|pgm|png|ppm|psd|ras|tga|tif|tiff|xbm|xpm|odg|otg|odc|odi|sds|doc|dot|rtf|sxw|stw|sdw|vor|txt|htm?|xml|wp|wpd|odt|ott|sxm|smf|mml|odf|sxi|sti|ppt|pps|pot|sxd|sda|sdd|sdp|vor|cgm|odp|otp|odb|sxc|stc|dif|dbf|xls|xlw|xlt|rtf|sdc|vor|slk|txt|htm|html|wk1|wks|123|xml|ods|ots|csv|sxg|xgl|txt|odm|sgl|stw|dot|vor|stc|xlt|sti|pot|std|stw|htm|html|stw|txt|vor|oth)' ;;
  43.     oowriter)        e='!*.+(doc|dot|rtf|sxw|stw|sdw|vor|txt|htm?|xml|wp|wpd|odt|ott)' ;;
  44.     ooimpress)        e='!*.+(sxi|sti|ppt|pps|pot|sxd|sda|sdd|sdp|vor|cgm|odp|otp)' ;;
  45.     *)            e='!*'
  46.     esac
  47.  
  48.     case "$(complete -p ${1##*/} 2> /dev/null)" in
  49.     *-d*)    ;;
  50.     *) s="-S/"
  51.     esac
  52.  
  53.     IFS='
  54. '
  55.     case "$c" in
  56.     \$\(*\))       eval COMPREPLY=\(${c}\) ;;
  57.     \$\(*)        COMPREPLY=($(compgen -c -P '$(' -S ')'  -- ${c#??}))    ;;
  58.     \`*\`)       eval COMPREPLY=\(${c}\) ;;
  59.     \`*)        COMPREPLY=($(compgen -c -P '\`' -S '\`' -- ${c#?}))    ;;
  60.     \$\{*\})       eval COMPREPLY=\(${c}\) ;;
  61.     \$\{*)        COMPREPLY=($(compgen -v -P '${' -S '}'  -- ${c#??}))    ;;
  62.     \$*)        COMPREPLY=($(compgen -v -P '$'          -- ${c#?}))    ;;
  63.     \~*/*)        COMPREPLY=($(compgen -f -X "$e"         -- ${c}))    ;;
  64.     \~*)        COMPREPLY=($(compgen -u ${s}         -- ${c}))    ;;
  65.     *@*)        COMPREPLY=($(compgen -A hostname -P '@' -S ':' -- ${c#*@})) ;;
  66.     *[*?[]*)        COMPREPLY=($(compgen -G "${c}"))            ;;
  67.     *[?*+\!@]\(*\)*)
  68.     if test $g -eq 0 ; then
  69.             COMPREPLY=($(compgen -f -X "$e" -- $c))
  70.             test $g -eq 0 && shopt -u extglob
  71.             return
  72.     fi
  73.             COMPREPLY=($(compgen -G "${c}"))            ;;
  74.     *)
  75.     if test "$c" = ".." ; then
  76.             COMPREPLY=($(compgen -d -X "$e" -S / ${_nosp} -- $c))
  77.     else
  78.             for s in $(compgen -f -X "$e" -- $c) ; do
  79.                 if test -d $s ; then
  80.                 COMPREPLY=(${COMPREPLY[@]} $(compgen -f -X "$e" -S / -- $s))
  81.                 elif test -z "$t" ; then
  82.                 COMPREPLY=(${COMPREPLY[@]} $s)
  83.                 else
  84.                 case "$(file -b $s 2> /dev/null)" in
  85.                 $t) COMPREPLY=(${COMPREPLY[@]} $s)        ;;
  86.                 esac
  87.                 fi
  88.             done
  89.     fi                                    ;;
  90.     esac
  91.     test $g -eq 0 && shopt -u extglob
  92. }
  93.  
  94.  
  95. complete -d -X '.[^./]*' -F _ooexp_ ${_file} \
  96.                     oobase \
  97.                     oofromtemplate \
  98.                     oodraw \
  99.                     oocalc \
  100.                     oomath \
  101.                     ooweb \
  102.                     ooffice \
  103.                     oowriter \
  104.                     ooimpress
  105.  
  106. unset _def _dir _file _nosp _minusdd _minusdf
  107.