44 lines
805 B
Bash
44 lines
805 B
Bash
#!/usr/bin/env bash
|
|
# Bash completion for dao command
|
|
|
|
_dao_completion() {
|
|
local cur commands
|
|
COMPREPLY=()
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
mapfile -t commands < <(printf "kitty\nmount\npwgen\nupdate\n")
|
|
|
|
case "${COMP_CWORD}" in
|
|
1)
|
|
mapfile -t COMPREPLY < <(compgen -W "${commands[*]}" -- "${cur}")
|
|
;;
|
|
2)
|
|
case "${COMP_WORDS[1]}" in
|
|
pwgen)
|
|
mapfile -t COMPREPLY < <(compgen -W "3 4 5 6 7 8 9 10" -- "${cur}")
|
|
;;
|
|
kitty)
|
|
mapfile -t COMPREPLY < <(compgen -W "--list --new-instance --new-tab" -- "${cur}")
|
|
;;
|
|
*) ;;
|
|
esac
|
|
;;
|
|
3)
|
|
case "${COMP_WORDS[1]}" in
|
|
pwgen)
|
|
if [[ "${COMP_WORDS[2]}" =~ ^[0-9]+$ ]]; then
|
|
mapfile -t COMPREPLY < <(compgen -W "- _ . space" -- "${cur}")
|
|
fi
|
|
;;
|
|
*) ;;
|
|
esac
|
|
;;
|
|
*)
|
|
;;
|
|
esac
|
|
|
|
return 0
|
|
}
|
|
|
|
complete -F _dao_completion dao.sh
|