dim-an / cod

cod is a completion daemon for bash/fish/zsh
Apache License 2.0
515 stars 25 forks source link

File completions are not optional #57

Open esauvisky opened 2 years ago

esauvisky commented 2 years ago

When learning new commands, cod forces the addition of file completions with compgen -f inside __cod_complete_bash, but there is no way to turn this behavior off.

Personally, I think this should at the very least be a toggleable flag. When using menu-completion=on, for example, filenames can really pollute the completions list according to how many files are in the current dir at that moment: Untitled

A temporary workaround is redefining the __cod_complete_bash function after the init script is sourced and commenting the line below:

    # Generate cod completions.
        #readarray -t COD_COMPLETIONS < <(command $__COD_BINARY api complete-words -- $$ "$COMP_CWORD" "${COMP_WORDS[@]}" 2> /dev/null)
dim-an commented 2 years ago

I've never used menu-completion=on myself. Could you please point me to documentation about it? Or give me a snippet how to enable it?

As for file completion I would really struggle without it. I personally use cod to complete arguments of my own helper scripts and they often accept file arguments. Disabling file completion for them looks like nightmare.

esauvisky commented 2 years ago

Sorry, I meant menu-complete, it's a bindable command from readline. Here's the documentation.

If you want to check out the exact setup I use to check the behavior, add this to your .inputrc:

set bind-tty-special-chars on
TAB: menu-complete
"\e[Z": menu-complete-backward
set menu-complete-display-prefix on
set show-all-if-ambiguous on
set show-all-if-unmodified on

But yes I understand disabling it altogether wouldn't be desirable either. Imho a way of toggling them off using the config file or by calling cod would be the best of both worlds, specially so if it possible to choose the behavior for each completion.

But I'm happy I was able to figure out how to disable them for my particular usecase. cod is really impressive, terrific job! 😊