Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change autocomplete keybind #410

Open
robertoash opened this issue Dec 6, 2023 · 1 comment
Open

Change autocomplete keybind #410

robertoash opened this issue Dec 6, 2023 · 1 comment

Comments

@robertoash
Copy link

I am wondering if it is possible to change the autocomplete keybind. I use zsh-autocomplete which also uses TAB for autocomplete so I am guessing the two are conflicting. If I could change the keybind via a config file to , for example, that would be a great solution.

I don't know enough about Python but I am learning. I tried to look at the code but couldn't find where TAB is defined as the autocomplete keybind. If you could point me in the right direction maybe I can try to figure out how to change it?

@varenc
Copy link

varenc commented Apr 19, 2024

You're talking about autocompletion for your shell? That's all handled by your shell and not something that's in the Python code or even in the shell code that defines the hass-cli autocompletion function. Are you sure that auto-completion for hass-cli is working for you? It should work peacefully with all your other shell completions.

On my zsh shell I see that the hass-cli completion is defined in the function _hass_cli_completion. I found this with echo $_comps[hass-cli]. If you don't see a completion there than you don't have it set up. I use zsh-autocomplete too and it works peacefully with the hass-cli completion.

Also here's the source of my _hass_cli_completion for reference:

#compdef hass-cli

_hass_cli_completion() {
    local -a completions
    local -a completions_with_descriptions
    local -a response
    (( ! $+commands[hass-cli] )) && return 1

    response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _HASS_CLI_COMPLETE=zsh_complete hass-cli)}")

    for type key descr in ${response}; do
        if [[ "$type" == "plain" ]]; then
            if [[ "$descr" == "_" ]]; then
                completions+=("$key")
            else
                completions_with_descriptions+=("$key":"$descr")
            fi
        elif [[ "$type" == "dir" ]]; then
            _path_files -/
        elif [[ "$type" == "file" ]]; then
            _path_files -f
        fi
    done

    if [ -n "$completions_with_descriptions" ]; then
        _describe -V unsorted completions_with_descriptions -U
    fi

    if [ -n "$completions" ]; then
        compadd -U -V unsorted -a completions
    fi
}

compdef _hass_cli_completion hass-cli;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants