File: mt-st.bash_completion

package info (click to toggle)
mt-st 1.8-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 320 kB
  • sloc: ansic: 1,647; makefile: 106; sh: 16
file content (47 lines) | stat: -rw-r--r-- 1,585 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#mt bash completion by Paweł Marciniak <sunwire<at>gmail.com>
#

_mt () {
    local cur prev words cword
    _init_completion || return

    #possible commands
    commands="weof wset eof fsf fsfm bsf bsfm fsr bsr fss bss rewind offline rewoffl eject retension eod seod seek tell status erase setblk lock unlock load compression setdensity drvbuffer stwrthreshold stoptions stsetoptions stclearoptions defblksize defdensity defdrvbuffer defcompression stsetcln sttimeout stlongtimeout densities setpartition mkpartition partseek asf stshowoptions"
    stoptions="buffer-writes async-writes read-ahead debug two-fms fast-eod no-wait weof-no-wait auto-lock def-writes can-bsr no-blklimits can-partitions scsi2logical sili sysv"

    COMPREPLY=()

    case $prev in
        -v | --version)
            return
            ;;
        -f )
            #list tape devices
            for tape in /sys/class/scsi_tape/*;
              do devs+="/dev/${tape##*/} ";
            done;
            COMPREPLY=($(compgen -W "$devs" -- "$cur"))
            return
            ;;
	stsetoptions)
	    # show list of stoptions
	    COMPREPLY=($(compgen -W "$stoptions" -- "$cur"))
            return
            ;;
    esac

    # if "$prev" is a substring of "$stoptions" show more "$stoptions"
    if [[ "$stoptions" == *"$prev"* ]]; then
	    COMPREPLY=($(compgen -W "$stoptions" -- "$cur"))
            return
    fi

    if [[ $cur == -* ]]; then
        COMPREPLY=($(compgen -W '-f -v' -- "$cur"))
        return
    fi

    COMPREPLY=($(compgen -W "$commands" -- "$cur"))

}
complete -F _mt mt