From 20da58084a68b118b15fa01228192463b61fa28f Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 5 Apr 2013 14:58:07 +0200 Subject: bash-completion: rename shell-completion -> bash-completion Signed-off-by: Karel Zak --- bash-completion/delpart | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 bash-completion/delpart (limited to 'bash-completion/delpart') diff --git a/bash-completion/delpart b/bash-completion/delpart new file mode 100644 index 000000000..e3ee40629 --- /dev/null +++ b/bash-completion/delpart @@ -0,0 +1,23 @@ +_delpart_module() +{ + local cur prev OPTS + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + case $COMP_CWORD in + 1) + local DEV TYPE DEVICES='' + while read DEV TYPE; do + [ $TYPE = 'disk' ] && DEVICES+="$DEV " + done < <(lsblk -pnro name,type) + OPTS="-h --help -V --version $DEVICES" + COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) + ;; + 2) + prev="${COMP_WORDS[COMP_CWORD-1]}" + COMPREPLY=( $(compgen -W "$(cat /sys/block/${prev##*/}/*/partition 2>/dev/null)" -- $cur) ) + ;; + esac + return 0 +} +complete -F _delpart_module delpart -- cgit v1.2.3-55-g7522