go-jira / jira

simple jira command line client in Go
Apache License 2.0
2.66k stars 323 forks source link

Zsh completion is not working #503

Closed dserodio closed 2 months ago

dserodio commented 2 months ago

After running eval $(jira --completion-script-zsh), the Zsh completion is not working (ie, jira <TAB> completes with a list of files.

This is the completion script itself (the output of jira --completion-script-zsh):

#compdef jira
autoload -U compinit && compinit
autoload -U bashcompinit && bashcompinit

_jira_bash_autocomplete() {
    local cur prev opts base
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    opts=$( ${COMP_WORDS[0]} --completion-bash ${COMP_WORDS[@]:1:$COMP_CWORD} )
    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
    return 0
}
complete -F _jira_bash_autocomplete jira

I tried to check if the bash completion worked, and I got a syntax error:

bash-5.2$ jira --completion-script-bash

_jira_bash_autocomplete() {
    local cur prev opts base
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    opts=$( ${COMP_WORDS[0]} --completion-bash ${COMP_WORDS[@]:1:$COMP_CWORD} )
    COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
    return 0
}
complete -F _jira_bash_autocomplete jira

bash-5.2$ eval $(jira --completion-script-bash)
bash: syntax error: unexpected end of file
dserodio commented 2 months ago

Something weird with my zsh completions setup, eval $(jira --completion-script-zsh) doesn't work but jira --completion-script-zsh > /tmp/jira-completion.zsh ; source /tmp/jira-completion.zsh works 🤔