1 # -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
2 # ex: ts=8 sw=8 noet filetype=sh
4 # mtx completion by Jon Middleton <jjm@ixtab.org.uk>
8 local cur prev options tapes drives
12 prev=${COMP_WORDS[COMP_CWORD-1]}
14 options="-f nobarcode invert noattach --version inquiry noattach \
15 inventory status load unload eepos first last next"
17 tapes=$(mtx status | \
18 awk '/Storage Element [0-9]+:Full/ { printf "%s ", $3 }')
21 drives=$(mtx status | \
22 awk '/Data Transfer Element [0-9]+:(Full|Empty)/ { printf "%s ", $4 }')
23 drives=${drives//:Full}
24 drives=${drives//:Empty}
26 if [ $COMP_CWORD -gt 1 ]; then
29 COMPREPLY=( $( compgen -W "$tapes" -- "$cur" ) )
31 @(unload|first|last|next))
32 COMPREPLY=( $( compgen -W "$drives" -- "$cur" ) )
39 COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )