Skip to content

git has duplicate subcommands completion #1197

Open

Description

@lomirus

add v.s. git add:

Image

Activity

  1. fdncred commented on Dec 26, 2025

    @fdncred
    Contributor

    Please be more specfic. This could be coming from your internal scripts, and external completer, some nu_scripts alias or module, etc.

  2. lomirus commented on Dec 28, 2025

    @lomirus
    Author

    By default, the completion for git ad + Tab looks like this:

    Image

    Then, after I add the following command to config.nu:

    source nu_scripts/custom-completions/git/git-completions.nu

    and restart the terminal, the git completion changes to the following:

    Image
  3. fdncred commented on Dec 28, 2025

    @fdncred
    Contributor

    Is it possible that the "add" is coming from normal git help? This is the man page. It doesn't appear to be coming from the git-completions.nu file, at least that text isn't in there.

    Image
  4. ysthakur commented on Dec 28, 2025

    @ysthakur
    Member

    This seems to be because the extern def for Git is defined with a command parameter that has its own completions:

    command?: string@"nu-complete git subcommands" # Subcommands

    Which uses git help to get all the subcommands (which is why it matches the manpage description, as @fdncred found)

    def "nu-complete git subcommands" [] {
    ^git help -a | lines | where $it starts-with " " | parse -r '\s*(?P<value>[^ ]+) \s*(?P<description>\w.*)'
    }

    I think the solution here could be to not have completions for the command parameter.

    One disadvantage of that solution is that if there's a new Git command that we don't have an extern def for, there won't be a completion suggestion for that subcommand name. But I think that's acceptable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions