# bash completion for dbanner # shellcheck shell=bash _dbanner() { local cur=${COMP_WORDS[COMP_CWORD]} if ((COMP_CWORD == 1)); then mapfile -t COMPREPLY < <(compgen -W "list show apply off on refresh help" -- "$cur") return fi case ${COMP_WORDS[1]} in show | apply) if [[ $cur == -* ]]; then mapfile -t COMPREPLY < <(compgen -W "--no-color" -- "$cur") else local names names=$(ls /usr/share/das/banner/presets "${XDG_CONFIG_HOME:-$HOME/.config}/das/banner" 2>/dev/null | sed -n 's/\.json$//p') mapfile -t COMPREPLY < <(compgen -W "$names" -- "$cur"; compgen -f -X '!*.json' -- "$cur") fi ;; refresh) mapfile -t COMPREPLY < <(compgen -W "--force" -- "$cur") ;; esac } complete -F _dbanner dbanner