Skip to content

[feature] Shell completion #5104

@Freed-Wu

Description

@Freed-Wu

Describe the issue

How about add bash/zsh/fish/posh/etc completion? Just like other git subcommands?

❯ git add --<TAB>
option
--all                  add, modify, and remove index entries to match the working tree
--chmod                override the executable bit of the listed files
--dry-run              do not actually add files; only show which ones would be added
--edit                 open diff against index in editor
--force                allow adding otherwise ignored files
--ignore-errors        continue adding if an error occurs
--ignore-removal       like "--all" but ignore removals
--intent-to-add        record only that path will be added later
...

A test example:

❯ compdef '_arguments -S -s "*: :((checkout\:'\''Populate working copy with real content from Git LFS files.'\'' dedup\:'\''De-duplicate Git LFS files.'\''))"' git-lfs
_arguments -S -s "*: :((checkout\:'Populate working copy with real content from Git LFS files.' dedup\:'De-duplicate Git LFS files.'))" git-lfs
❯ git-lfs <TAB>
checkout   Populate working copy with real content from Git LFS files.
dedup      De-duplicate Git LFS files.

I guess https://jmtirado.net/shell-completion-with-cobra-and-go/ and https://github.com/cli/cli/blob/cf4b73ff958b272cf3c9c0cf9351459f76b793a0/pkg/cmd/completion/completion.go may be helpful?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions