]> git.ipfire.org Git - thirdparty/util-linux.git/blame_incremental - bash-completion/swapon
su: use lib/pty-session.c code for --pty
[thirdparty/util-linux.git] / bash-completion / swapon
... / ...
CommitLineData
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 --priority
63 --summary
64 --show
65 --output-all
66 --noheadings
67 --raw
68 --bytes
69 --verbose
70 -L
71 -U
72 --help
73 --version"
74 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
75 return 0
76 ;;
77 esac
78 local DEVS
79 DEVS="$(lsblk -nrp -o FSTYPE,NAME | awk '$1 ~ /swap/ { print $2 }')"
80 compopt -o nospace
81 COMPREPLY=( $(compgen -fW "$DEVS LABEL= UUID= PARTLABEL= PARTUUID=" -- $cur) )
82 return 0
83}
84complete -F _swapon_module swapon