]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
bash-completion: add swapon specifiers to completion
authorSami Kerola <kerolasa@iki.fi>
Thu, 10 May 2018 20:02:00 +0000 (21:02 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 28 May 2018 11:36:38 +0000 (13:36 +0200)
No space after device name is not entirely right, but that's better than
missing argument completions.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
bash-completion/swapon

index f5136efd3181a8e68574bc9aefe8516dc41ee28f..a6b6f092119f91677ffa2d2b4cc7394230389495 100644 (file)
@@ -25,18 +25,30 @@ _swapon_module()
                        COMPREPLY=( $(compgen -P "$prefix" -W "$OUTPUT" -S ',' -- $realcur) )
                        return 0
                        ;;
-               '-U')
+               '-U'|'UUID=')
                        local UUIDS
                        UUIDS="$(lsblk -nrp -o FSTYPE,UUID | awk '$1 ~ /swap/ { print $2 }')"
                        COMPREPLY=( $(compgen -W "$UUIDS" -- $cur) )
                        return 0
                        ;;
-               '-L')
+               '-L'|'LABEL=')
                        local LABELS
                        LABELS="$(lsblk -nrp -o FSTYPE,LABEL | awk '$1 ~ /swap/ { print $2 }')"
                        COMPREPLY=( $(compgen -W "$LABELS" -- $cur) )
                        return 0
                        ;;
+               'PARTUUID=')
+                       local PARTUUIDS
+                       PARTUUIDS="$(lsblk -nrp -o FSTYPE,PARTUUID | awk '$1 ~ /swap/ { print $2 }')"
+                       COMPREPLY=( $(compgen -W "$PARTUUIDS" -- $cur) )
+                       return 0
+                       ;;
+               'PARTLABEL=')
+                       local PARTLABELS
+                       PARTLABELS="$(lsblk -nrp -o FSTYPE,PARTLABEL | awk '$1 ~ /swap/ { print $2 }')"
+                       COMPREPLY=( $(compgen -W "$PARTLABELS" -- $cur) )
+                       return 0
+                       ;;
                '-h'|'--help'|'-V'|'--version')
                        return 0
                        ;;
@@ -55,6 +67,8 @@ _swapon_module()
                                --raw
                                --bytes
                                --verbose
+                               -L
+                               -U
                                --help
                                --version"
                        COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
@@ -63,7 +77,8 @@ _swapon_module()
        esac
        local DEVS
        DEVS="$(lsblk -nrp -o FSTYPE,NAME | awk '$1 ~ /swap/ { print $2 }')"
-       COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
+       compopt -o nospace
+       COMPREPLY=( $(compgen -fW "$DEVS LABEL= UUID= PARTLABEL= PARTUUID=" -- $cur) )
        return 0
 }
 complete -F _swapon_module swapon