Debian Codegraph @

bash-completion/swapon

raw
1 _swapon_module()
2 {
3 local cur prev OPTS
4 COMPREPLY=()
5 cur="${COMP_WORDS[COMP_CWORD]}"
6 prev="${COMP_WORDS[COMP_CWORD-1]}"
7 case $prev in
8 '-p'|'--priority')
9 # Priority range is -1 to 32767. Perhaps these
10 # few are enough.
11 COMPREPLY=( $(compgen -W "{-1..9} 32767" -- $cur) )
12 return 0
13 ;;
14 '--show')
15 local prefix realcur OUTPUT_ALL OUTPUT
16 realcur="${cur##*,}"
17 prefix="${cur%$realcur}"
18 OUTPUT_ALL="NAME TYPE SIZE USED PRIO UUID LABEL"
19 for WORD in $OUTPUT_ALL; do
20 if ! [[ $prefix == *"$WORD"* ]]; then
21 OUTPUT="$WORD ${OUTPUT:-""}"
22 fi
23 done
24 compopt -o nospace
25 COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) )
26 return 0
27 ;;
28 '-U'|'UUID=')
29 local UUIDS
30 UUIDS="$(command lsblk -nrp -o FSTYPE,UUID | command awk '$1 ~ /swap/ { print $2 }')"
31 COMPREPLY=( $(compgen -W "$UUIDS" -- $cur) )
32 return 0
33 ;;
34 '-L'|'LABEL=')
35 local LABELS
36 LABELS="$(command lsblk -nrp -o FSTYPE,LABEL | command awk '$1 ~ /swap/ { print $2 }')"
37 COMPREPLY=( $(compgen -W "$LABELS" -- $cur) )
38 return 0
39 ;;
40 'PARTUUID=')
41 local PARTUUIDS
42 PARTUUIDS="$(command lsblk -nrp -o FSTYPE,PARTUUID | command awk '$1 ~ /swap/ { print $2 }')"
43 COMPREPLY=( $(compgen -W "$PARTUUIDS" -- $cur) )
44 return 0
45 ;;
46 'PARTLABEL=')
47 local PARTLABELS
48 PARTLABELS="$(command lsblk -nrp -o FSTYPE,PARTLABEL | command awk '$1 ~ /swap/ { print $2 }')"
49 COMPREPLY=( $(compgen -W "$PARTLABELS" -- $cur) )
50 return 0
51 ;;
52 '-h'|'--help'|'-V'|'--version')
53 return 0
54 ;;
55 esac
56 case $cur in
57 -*)
58 OPTS="--all
59 --annotate
60 --discard
61 --ifexists
62 --fixpgsz
63 --fstab
64 --priority
65 --summary
66 --show
67 --output-all
68 --options
69 --noheadings
70 --raw
71 --bytes
72 --verbose
73 -L
74 -U
75 --help
76 --version"
77 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
78 return 0
79 ;;
80 esac
81 local DEVS
82 DEVS="$(command lsblk -nrp -o FSTYPE,NAME | command awk '$1 ~ /swap/ { print $2 }')"
83 compopt -o nospace
84 COMPREPLY=( $(compgen -fW "$DEVS LABEL= UUID= PARTLABEL= PARTUUID=" -- $cur) )
85 return 0
86 }
87 complete -F _swapon_module swapon