~ubuntu-branches/ubuntu/vivid/bash-completion/vivid-proposed

« back to all changes in this revision

Viewing changes to contrib/mtx

  • Committer: Package Import Robot
  • Author(s): Angel Abad
  • Date: 2011-02-08 09:39:13 UTC
  • mfrom: (5.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20110208093913-89h9hx9eq5j7vjpw
Tags: 1:1.3-1ubuntu1
* Merge from debian unstable. (LP: #715057) Remaining changes:
  - debian/patches/disable-avahi-browse.diff: Disable avahi-browse since
    it scales poorly in the current form:
    + Refresh patch
  - debian/patches/apt-get-changelog.patch:
    + Re-work patch because contrib dir no longer exists in upstream
      distribution.
* Dropped chages, applied upstream:
  - Fix p4 completion
  - Fix typo in openssl completion
  - Fix error while loading service(8) completions

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# mtx completion by Jon Middleton <jjm@ixtab.org.uk>
2
 
 
3
 
have mtx &&
4
 
_mtx()
5
 
{
6
 
    local cur prev options tapes drives
7
 
 
8
 
    COMPREPLY=()
9
 
    _get_comp_words_by_ref cur prev
10
 
 
11
 
    options="-f nobarcode invert noattach --version inquiry noattach \
12
 
        inventory status load unload eepos first last next"
13
 
 
14
 
    tapes=$(mtx status | \
15
 
        awk '/Storage Element [0-9]+:Full/ { printf "%s ", $3 }')
16
 
    tapes=${tapes//:Full}
17
 
 
18
 
    drives=$(mtx status | \
19
 
        awk '/Data Transfer Element [0-9]+:(Full|Empty)/ { printf "%s ", $4 }')
20
 
    drives=${drives//:Full}
21
 
    drives=${drives//:Empty}
22
 
 
23
 
    if [ $COMP_CWORD -gt 1 ]; then
24
 
        case $prev in
25
 
            load)
26
 
                COMPREPLY=( $( compgen -W "$tapes" -- "$cur" ) )
27
 
                ;;
28
 
            unload|first|last|next)
29
 
                COMPREPLY=( $( compgen -W "$drives" -- "$cur" ) )
30
 
                ;;
31
 
            -f)
32
 
                true
33
 
                ;;
34
 
            *)
35
 
                true
36
 
                ;;
37
 
        esac
38
 
    else
39
 
        COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
40
 
    fi
41
 
    return 0
42
 
} &&
43
 
complete -F _mtx mtx
44
 
 
45
 
# Local variables:
46
 
# mode: shell-script
47
 
# sh-basic-offset: 4
48
 
# sh-indent-comment: t
49
 
# indent-tabs-mode: nil
50
 
# End:
51
 
# ex: ts=4 sw=4 et filetype=sh