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

Add bash completion scripts #66

Open
Chairn opened this issue Oct 16, 2023 · 2 comments
Open

Add bash completion scripts #66

Chairn opened this issue Oct 16, 2023 · 2 comments

Comments

@Chairn
Copy link

Chairn commented Oct 16, 2023

Hello,

It would be nice to have bash auto complete either files or command just like any other git commands. I tried to look at git-completions, but it's hard to understand how it works.

By default, on Debian 12, "git rest" autocomplete to "git restore " and not "git restore" which means we have to backtrack one character (the space after restore) and then type "-mtime" manually. Afterwards, no completion occurs, neither for files nor for options.

I don't know if it's easily doable.
Thanks

@MestreLion
Copy link
Owner

There are 2 "tiers" of bash-completion for git: the easy one, that simply completes the subcommand, so git rest<TAB> expands to git restore-mtime. And the tricky one, that autocompletes arguments based on current subcommand.

The former already works, provided you've installed git-restore-mtime anywhere in your $PATH. git itself does that for all available subcommands, nothing required on my part.

The latter would require actual implementation on my part, it's in my TO-DO list but I don't believe I'll do it in the near (or even mid) future.

However, I know there are tools to auto-generate bash-completions based on --help output, and some for Python scripts that use argparse (as is the case of git-restore-mtime that are even more accurate than --help parsing. This way anyone can have bash-completions for any command without any intervention or support on the command's part. This could be a workaround until someone PR an actual support.

@MestreLion
Copy link
Owner

Btw, it seems git restore is a new, experimental command, which I don't have here. Maybe its existence is messing with git's own subcommand completion mechanism?

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

2 participants