diff options
Diffstat (limited to 'bash-completion/delpart')
-rw-r--r-- | bash-completion/delpart | 23 |
1 files changed, 23 insertions, 0 deletions
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 |