diff --git a/scripts/bash-completion.sh b/scripts/bash-completion.sh index 47f50cf..9c663b9 100644 --- a/scripts/bash-completion.sh +++ b/scripts/bash-completion.sh @@ -1,15 +1,24 @@ # Bash autocomplete script for yerbacon +function YCompReply() { mapfile -t COMPREPLY <<< "$1"; } + _ybconAutoComplete() { + compopt +o default local current previous options COMPREPLY=() current="${COMP_WORDS[COMP_CWORD]}" previous="${COMP_WORDS[COMP_CWORD-1]}" options='-h -p --help --printresult --version' if [[ "${current}" == -* ]]; then - mapfile -t COMPREPLY <<< "$(compgen -W "$options" -- "$current") " + YCompReply "$(compgen -W "$options" -- "$current")" return 0 + else + case "${previous}" in + -h | --help | --version ) + exit 0 ;; + esac + complete -f -o plusdirs -X '!*.ybcon' ybcon fi } -complete -o nospace -F _ybconAutoComplete ybcon \ No newline at end of file +complete -F _ybconAutoComplete ybcon \ No newline at end of file