diff options
Diffstat (limited to 'completions/mtx')
-rw-r--r-- | completions/mtx | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/completions/mtx b/completions/mtx index 0454f032..0dae92ae 100644 --- a/completions/mtx +++ b/completions/mtx @@ -1,26 +1,26 @@ -# mtx completion by Jon Middleton <jjm@ixtab.org.uk> +# mtx completion -*- shell-script -*- +# by Jon Middleton <jjm@ixtab.org.uk> -have mtx && _mtx() { - local cur prev options tapes drives + local cur prev words cword + _init_completion || return - COMPREPLY=() - _get_comp_words_by_ref cur prev + local options tapes drives options="-f nobarcode invert noattach --version inquiry noattach \ inventory status load unload eepos first last next" - tapes=$(mtx status | \ + tapes=$(mtx status 2>/dev/null | \ awk '/Storage Element [0-9]+:Full/ { printf "%s ", $3 }') tapes=${tapes//:Full} - drives=$(mtx status | \ + drives=$(mtx status 2>/dev/null | \ awk '/Data Transfer Element [0-9]+:(Full|Empty)/ { printf "%s ", $4 }') drives=${drives//:Full} drives=${drives//:Empty} - if [ $COMP_CWORD -gt 1 ]; then + if [ $cword -gt 1 ]; then case $prev in load) COMPREPLY=( $( compgen -W "$tapes" -- "$cur" ) ) @@ -42,10 +42,4 @@ _mtx() } && complete -F _mtx mtx -# Local variables: -# mode: shell-script -# sh-basic-offset: 4 -# sh-indent-comment: t -# indent-tabs-mode: nil -# End: # ex: ts=4 sw=4 et filetype=sh |