]> git.ipfire.org Git - thirdparty/util-linux.git/blob - bash-completion/swapon
nsenter: add option `-c` to join the cgroup of target process
[thirdparty/util-linux.git] / bash-completion / swapon
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="$(lsblk -nrp -o FSTYPE,UUID | awk '$1 ~ /swap/ { print $2 }')"
31 COMPREPLY=( $(compgen -W "$UUIDS" -- $cur) )
32 return 0
33 ;;
34 '-L'|'LABEL=')
35 local LABELS
36 LABELS="$(lsblk -nrp -o FSTYPE,LABEL | awk '$1 ~ /swap/ { print $2 }')"
37 COMPREPLY=( $(compgen -W "$LABELS" -- $cur) )
38 return 0
39 ;;
40 'PARTUUID=')
41 local PARTUUIDS
42 PARTUUIDS="$(lsblk -nrp -o FSTYPE,PARTUUID | awk '$1 ~ /swap/ { print $2 }')"
43 COMPREPLY=( $(compgen -W "$PARTUUIDS" -- $cur) )
44 return 0
45 ;;
46 'PARTLABEL=')
47 local PARTLABELS
48 PARTLABELS="$(lsblk -nrp -o FSTYPE,PARTLABEL | 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 --discard
60 --ifexists
61 --fixpgsz
62 --fstab
63 --priority
64 --summary
65 --show
66 --output-all
67 --noheadings
68 --raw
69 --bytes
70 --verbose
71 -L
72 -U
73 --help
74 --version"
75 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
76 return 0
77 ;;
78 esac
79 local DEVS
80 DEVS="$(lsblk -nrp -o FSTYPE,NAME | awk '$1 ~ /swap/ { print $2 }')"
81 compopt -o nospace
82 COMPREPLY=( $(compgen -fW "$DEVS LABEL= UUID= PARTLABEL= PARTUUID=" -- $cur) )
83 return 0
84 }
85 complete -F _swapon_module swapon