diff options
Diffstat (limited to 'completions/mtx')
-rw-r--r-- | completions/mtx | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/completions/mtx b/completions/mtx index 9266687c..b5c270bd 100644 --- a/completions/mtx +++ b/completions/mtx @@ -11,22 +11,22 @@ _mtx() options="-f nobarcode invert noattach --version inquiry noattach \ inventory status load unload eepos first last next" - tapes=$(mtx status 2>/dev/null | \ + tapes=$(mtx status 2>/dev/null | awk '/Storage Element [0-9]+:Full/ { printf "%s ", $3 }') - tapes=${tapes//:Full} + tapes=${tapes//:Full/} - drives=$(mtx status 2>/dev/null | \ + drives=$(mtx status 2>/dev/null | awk '/Data Transfer Element [0-9]+:(Full|Empty)/ { printf "%s ", $4 }') - drives=${drives//:Full} - drives=${drives//:Empty} + drives=${drives//:Full/} + drives=${drives//:Empty/} - if [[ $cword -gt 1 ]]; then + if ((cword > 1)); then case $prev in load) - COMPREPLY=( $(compgen -W "$tapes" -- "$cur") ) + COMPREPLY=($(compgen -W "$tapes" -- "$cur")) ;; - unload|first|last|next) - COMPREPLY=( $(compgen -W "$drives" -- "$cur") ) + unload | first | last | next) + COMPREPLY=($(compgen -W "$drives" -- "$cur")) ;; -f) true @@ -36,9 +36,9 @@ _mtx() ;; esac else - COMPREPLY=( $(compgen -W "$options" -- "$cur") ) + COMPREPLY=($(compgen -W "$options" -- "$cur")) fi } && -complete -F _mtx mtx + complete -F _mtx mtx # ex: filetype=sh |