]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
bash-completion: add blkreset and blkreport completion
authorSami Kerola <kerolasa@iki.fi>
Sat, 11 Feb 2017 14:10:52 +0000 (14:10 +0000)
committerKarel Zak <kzak@redhat.com>
Mon, 13 Feb 2017 13:14:28 +0000 (14:14 +0100)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
bash-completion/blkreset [new file with mode: 0755]

diff --git a/bash-completion/blkreset b/bash-completion/blkreset
new file mode 100755 (executable)
index 0000000..69c5f63
--- /dev/null
@@ -0,0 +1,34 @@
+_blkreset_module()
+{
+       local cur prev OPTS
+       COMPREPLY=()
+       cur="${COMP_WORDS[COMP_CWORD]}"
+       prev="${COMP_WORDS[COMP_CWORD-1]}"
+       case $prev in
+               '-z'|'--zone')
+                       COMPREPLY=( $(compgen -W "offset" -- $cur) )
+                       return 0
+                       ;;
+               '-c'|'--count')
+                       COMPREPLY=( $(compgen -W "length" -- $cur) )
+                       return 0
+                       ;;
+               '-h'|'--help'|'-V'|'--version')
+                       return 0
+                       ;;
+       esac
+       case $cur in
+               -*)
+                       OPTS="--zone --count --version --help"
+                       if [ "$1" = 'blkreport' ]; then
+                               OPTS+=' --verbose'
+                       fi
+                       COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+                       return 0
+                       ;;
+       esac
+       COMPREPLY=( $(compgen -W "$(lsblk -pnro name)" -- $cur) )
+       return 0
+}
+complete -F _blkreset_module blkreset
+complete -F _blkreset_module blkreport