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 / mtx < prev    next >
Encoding:
Text File  |  2006-08-28  |  1.0 KB  |  46 lines

  1. # mtx completion by Jon Middleton <jjm@ixtab.org.uk>
  2. #
  3. # $Id: mtx,v 1.1 2004/01/01 00:54:41 ianmacd Exp $
  4.  
  5. _mtx()
  6. {
  7.     local cur prev options tapes drives
  8.     
  9.     COMPREPLY=()
  10.     cur=${COMP_WORDS[COMP_CWORD]}
  11.     prev=${COMP_WORDS[COMP_CWORD-1]}
  12.  
  13.     options="-f nobarcode invert noattach --version inquiry noattach \
  14.              inventory status load unload eepos first last next"
  15.  
  16.     tapes=$(mtx status | \
  17.     awk '/Storage Element [0-9]+:Full/ { printf "%s ", $3 }')
  18.     tapes=${tapes//:Full}
  19.  
  20.     drives=$(mtx status | \
  21.          awk '/Data Transfer Element [0-9]+:(Full|Empty)/ { printf "%s ", $4 }')
  22.     drives=${drives//:Full}
  23.     drives=${drives//:Empty}
  24.  
  25.     if [ $COMP_CWORD -gt 1 ]; then
  26.     case $prev in 
  27.         load) 
  28.         COMPREPLY=( $( compgen -W "$tapes" -- $cur ) )        
  29.         ;;
  30.         unload|first|last|next)
  31.         COMPREPLY=( $( compgen -W "$drives" -- $cur ) )
  32.         ;;
  33.         -f)
  34.         true
  35.         ;;
  36.         *)
  37.         true
  38.         ;;
  39.     esac
  40.     else
  41.         COMPREPLY=( $( compgen -W "$options" -- $cur ) )
  42.     fi
  43.     return 0
  44. complete -F _mtx mtx
  45.