summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Kerola2018-05-10 22:02:00 +0200
committerKarel Zak2018-05-28 13:36:38 +0200
commitfaa44b6d9aa1449db5f1161930a1d914566b6f61 (patch)
tree0fd0756d855779a7237d80b8aeebd68d76bca6ce
parentrev: move a global variable to local scope (diff)
downloadkernel-qcow2-util-linux-faa44b6d9aa1449db5f1161930a1d914566b6f61.tar.gz
kernel-qcow2-util-linux-faa44b6d9aa1449db5f1161930a1d914566b6f61.tar.xz
kernel-qcow2-util-linux-faa44b6d9aa1449db5f1161930a1d914566b6f61.zip
bash-completion: add swapon specifiers to completion
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>
-rw-r--r--bash-completion/swapon21
1 files changed, 18 insertions, 3 deletions
diff --git a/bash-completion/swapon b/bash-completion/swapon
index f5136efd3..a6b6f0921 100644
--- a/bash-completion/swapon
+++ b/bash-completion/swapon
@@ -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