1 # mtx completion by Jon Middleton <jjm@ixtab.org.uk>
3 # $Id: bash_completion,v 1.1 2004-02-15 05:43:25 bdale Exp $
7 local cur prev options tapes drives
10 cur=${COMP_WORDS[COMP_CWORD]}
11 prev=${COMP_WORDS[COMP_CWORD-1]}
13 options="-f nobarcode invert noattach --version inquiry noattach \
14 inventory status load unload eepos first last next"
16 tapes=$(mtx status | \
17 awk '/Storage Element [0-9]+:Full/ { printf "%s ", $3 }')
20 drives=$(mtx status | \
21 awk '/Data Transfer Element [0-9]+:(Full|Empty)/ { printf "%s ", $4 }')
22 drives=${drives//:Full}
23 drives=${drives//:Empty}
25 if [ $COMP_CWORD -gt 1 ]; then
28 COMPREPLY=( $( compgen -W "$tapes" -- $cur ) )
30 unload|first|last|next)
31 COMPREPLY=( $( compgen -W "$drives" -- $cur ) )
41 COMPREPLY=( $( compgen -W "$options" -- $cur ) )