Debian Codegraph @

mt-st.bash_completion

raw
1 #mt bash completion by Paweł Marciniak <sunwire<at>gmail.com>
2 #
3
4 _mt () {
5 local cur prev words cword
6 _init_completion || return
7
8 #possible commands
9 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"
10 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"
11
12 COMPREPLY=()
13
14 case $prev in
15 -v | --version)
16 return
17 ;;
18 -f )
19 #list tape devices
20 for tape in /sys/class/scsi_tape/*;
21 do devs+="/dev/${tape##*/} ";
22 done;
23 COMPREPLY=($(compgen -W "$devs" -- "$cur"))
24 return
25 ;;
26 stsetoptions)
27 # show list of stoptions
28 COMPREPLY=($(compgen -W "$stoptions" -- "$cur"))
29 return
30 ;;
31 esac
32
33 # if "$prev" is a substring of "$stoptions" show more "$stoptions"
34 if [[ "$stoptions" == *"$prev"* ]]; then
35 COMPREPLY=($(compgen -W "$stoptions" -- "$cur"))
36 return
37 fi
38
39 if [[ $cur == -* ]]; then
40 COMPREPLY=($(compgen -W '-f -v' -- "$cur"))
41 return
42 fi
43
44 COMPREPLY=($(compgen -W "$commands" -- "$cur"))
45
46 }
47 complete -F _mt mt