home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / doc / bash / completion-contrib / povray < prev    next >
Encoding:
Text File  |  2006-08-28  |  1.7 KB  |  59 lines

  1. # povray completion by "David Necas (Yeti)" <yeti@physics.muni.cz>
  2. #
  3. # $Id: povray,v 1.2 2003/12/31 08:22:37 ianmacd Exp $
  4.  
  5. _povray()
  6. {
  7.   local cur prev povcur pfx oext defoext
  8.   defoext=png # default output extension, if cannot be determined FIXME
  9.  
  10.   COMPREPLY=()
  11.   povcur=${COMP_WORDS[COMP_CWORD]}
  12.   prev=${COMP_WORDS[COMP_CWORD-1]}
  13.  
  14.   _expand || return 0
  15.  
  16.   case $povcur in
  17.     [-+]I*)
  18.     cur="${povcur#[-+]I}" # to confuse _filedir
  19.     pfx="${povcur%"$cur"}"
  20.     _filedir pov
  21.     COMPREPLY=( ${COMPREPLY[@]/#/$pfx} )
  22.     return 0
  23.     ;;
  24.     [-+]O*)
  25.     # guess what output file type user may want
  26.     case $( ( IFS=$'\n'; echo "${COMP_WORDS[*]}" | grep '^[-+]F' ) ) in
  27.       [-+]FN) oext=png ;;
  28.       [-+]FP) oext=ppm ;;
  29.       [-+]F[CT]) oext=tga ;;
  30.       *) oext=$defoext ;;
  31.     esac
  32.     # complete filename corresponding to previously specified +I
  33.     COMPREPLY=( $( ( IFS=$'\n'; echo "${COMP_WORDS[*]}" | grep '^[-+]I' ) ) )
  34.     COMPREPLY=( ${COMPREPLY[@]#[-+]I} )
  35.     COMPREPLY=( ${COMPREPLY[@]/%.pov/.$oext} )
  36.     cur="${povcur#[-+]O}" # to confuse _filedir
  37.     pfx="${povcur%"$cur"}"
  38.     _filedir $oext
  39.     COMPREPLY=( ${COMPREPLY[@]/#/$pfx} )
  40.     return 0
  41.     ;;
  42.     *.ini\[|*.ini\[*[^]]) # sections in .ini files
  43.     cur="${povcur#*\[}"
  44.     pfx="${povcur%\["$cur"}" # prefix == filename
  45.     [ -r "$pfx" ] || return 0
  46.     COMPREPLY=( $(sed -e 's/^[[:space:]]*\[\('"$cur"'[^]]*\]\).*$/\1/' -e 't' -e 'd' -- "$pfx") )
  47.     # to prevent [bar] expand to nothing.  can be done more easily?
  48.     COMPREPLY=( "${COMPREPLY[@]/#/$pfx[}" )
  49.     return 0
  50.     ;;
  51.     *)
  52.     cur="$povcur"
  53.     _filedir '?(ini|pov)'
  54.     return 0
  55.     ;;
  56.   esac
  57. }
  58. complete -F _povray -o filenames povray xpovray spovray
  59.