Skip to content

git and gh completions: one extern per tool, alias-aware, full coverage - #1312

Merged
fdncred merged 1 commit into
nushell:mainfrom
fdncred:update_gh_git_completions
Nov 16, 2026
Merged

fdncred merged 1 commit into
nushell:mainfrom
fdncred:update_gh_git_completions

Conversation

@fdncred

@fdncred fdncred commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Description

custom-completions/git and custom-completions/gh drop their per-subcommand externs (57 for git, 40 for gh). Each file now has a single extern with no declared flags, plus a completer that works out the command from the words on the line.

How one git tab press is resolved:

nu-complete git
  skip global options; honor -C, --git-dir, --work-tree
  expand git aliases          co -> checkout,  `!git switch $1` -> switch
  find the subcommand         stash show, remote add, worktree remove, ...
  word starts with `-`        -> flags from `git <builtin> -h`, hand tables for scripts,
                                 shared @rev/@diff sets; `--opt=` values; `--no-*` after `--no`
  previous word takes a value -> GIT_FLAG_VALUES: list | completer | path
  otherwise                   -> GIT_POSITIONALS slot -> refs, branches, remotes, stashes,
                                 worktrees, submodules, config keys, changed files, ...

Declaring no flags is deliberate. Every declared flag changes what git or gh receives:

  • Switches: --x=v fails to parse, and gh's --draft=false is sent as --draft false.
  • Valued flags: a bare --x at the end of the line fails to parse.
  • Short flags with a value: attached values (-n5, -Xtheirs, -uno) fail to parse.
  • Short-to-long rewriting: declared shorts are sent as their long names, and the old top-level git extern applied that to aliases (see Evidence).
  • --help: prints Nushell's help instead of the tool's.

Undeclared arguments pass through untouched, and the completer still offers every flag.

@fdncred
fdncred force-pushed the update_gh_git_completions branch from 2777e50 to 3cac6bd Compare November 16, 2026 17:18
@fdncred
fdncred merged commit cfee661 into nushell:main Nov 16, 2026
1 check passed
@fdncred
fdncred deleted the update_gh_git_completions branch November 16, 2026 17:20
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

Successfully merging this pull request may close these issues.

1 participant