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

cod should check for existing completions for aliased commands #6

Open
zachriggle opened this issue Feb 12, 2020 · 0 comments
Open

Comments

@zachriggle
Copy link

zachriggle commented Feb 12, 2020

I have a bunch of wrapper scripts around ripgrep rg, and I alias all of their completions to rg since the arguments get passed-through.

Autocompletion already works in this manner, so cod should not try to learn them.

$ cat bin/example-script
#!/usr/bin/env zsh
rg "$@"
$ example-script <tab>
 -- option --
--after-context                 -A  -- specify lines to show after each match
--and                               -- Logical AND
--auto-hybrid-regex                 -- dynamically use PCRE2 if necessary
--before-context                -B  -- specify lines to show before each match
--binary                            -- search binary files, don't print binary data
--block-buffered                    -- force block buffering
--byte-offset                   -b  -- show 0-based byte offset for each matching line
--case-sensitive                -s  -- search case-sensitively

However, cod tries to learn it when passing --help.

$ example-script --help
...
OPTIONS:
    -A, --after-context <NUM>
...
┌──> /Users/zachriggle/..../bin/example-script --help
└─── cod: learn this command? [yn?] >

Here's how they are registered, tldr is compdef mycommand=rg.

#!/usr/bin/env zsh
BINDIR="${0:h}/bin"
path=("$BINDIR" $path)

for script in "$BINDIR"/*(*); do
    name="$script:t"
    compdef "$name"=rg
done

There is no fpath entry for these, they are just compdef aliases. This should be consulted before offering to learn a command.

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

1 participant