| 1 |
# dl-distro Bash completions |
| 2 |
|
| 3 |
_dl_compgen() |
| 4 |
{ |
| 5 |
local i r |
| 6 |
|
| 7 |
COMPREPLY=($(compgen -W '$*' -- "$cur")) |
| 8 |
|
| 9 |
for ((i = 1; i < ${#COMP_WORDS[@]} - 1; i++)); do |
| 10 |
for r in ${!COMPREPLY[@]}; do |
| 11 |
if [[ ${COMP_WORDS[i]} == ${COMPREPLY[r]} ]]; then |
| 12 |
unset 'COMPREPLY[r]' |
| 13 |
break |
| 14 |
fi |
| 15 |
done |
| 16 |
done |
| 17 |
} |
| 18 |
|
| 19 |
_dl_distro() |
| 20 |
{ |
| 21 |
local short_opts long_opts distros |
| 22 |
local cur prev words cword |
| 23 |
|
| 24 |
_init_completion || return |
| 25 |
|
| 26 |
short_opts=('-a -c -d -D -h -i -l -L -m -n -p -P -s -u -V') |
| 27 |
long_opts=('--auto-update --conf-file --distro --delete-key --help |
| 28 |
--import-key --list-keys --list-distros --manual-download --no-verify --path |
| 29 |
--purge-data --spider --update-json --version') |
| 30 |
distros=('alma alpine arch cachy debian deepin dragora endeavour fedora ghostbsd gparted guix |
| 31 |
hyperbola kali mint mxlinux nix nobara openbsd opensuse parabola parch |
| 32 |
parrot pop proxmox pure qubes rocky slackware solus tails tinycore |
| 33 |
trisquel ubuntu void whonix zorin') |
| 34 |
|
| 35 |
case "$prev" in |
| 36 |
-d|--distro) |
| 37 |
_dl_compgen "$distros" |
| 38 |
;; |
| 39 |
-i|--import-key) |
| 40 |
_filedir |
| 41 |
;; |
| 42 |
-p|--path) |
| 43 |
_filedir -d |
| 44 |
;; |
| 45 |
*) |
| 46 |
if [[ "$cur" == --* ]]; then |
| 47 |
_dl_compgen "$long_opts" |
| 48 |
elif [[ "$cur" == -* ]]; then |
| 49 |
_dl_compgen "$short_opts" |
| 50 |
fi |
| 51 |
;; |
| 52 |
esac |
| 53 |
} |
| 54 |
|
| 55 |
complete -F _dl_distro dl-distro |
| 56 |
|
| 57 |
# ex: ft=sh |