You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
A lot of Bash CLI tools provide a command line option to output a completion script. For example, ripgrep provides an option:
$ rg --generate=complete-bash | head -5
_rg() {
local i cur prev opts cmds
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
This can be called in a .bashrc file, to enable command line completion:
source <(rg --generate=complete-bash)
It would be nice if Amber supported this.
Describe the solution you'd like
Since we already use the clap library, we can use the complementary clap_complete library to do this.
No, I'm talking about tab completion on the command line, not keyword completion in an IDE. Suppose I want to type git commit. If I type this:
$ git co<Tab><Tab>
I get this, where | represents the cursor:
$ git co
co commit config
$ git co|
If I then type this:
$ git com<Tab>
I get this:
$ git commit |
Whenever the user presses the Tab key, Bash parses the command line so far, and calls the relevant completion script. It then offers completion options according to the output of that script. The clap library has a feature where you can generate completion scripts automatically.
I've assigned this and #411 to myself; might as well do both at the same time.
hdwalters
changed the title
[Feature] Add command line option to print Bash completion script
[Feature] Add option to print Bash completion script
Nov 3, 2024
Is your feature request related to a problem? Please describe.
A lot of Bash CLI tools provide a command line option to output a completion script. For example,
ripgrep
provides an option:This can be called in a
.bashrc
file, to enable command line completion:It would be nice if Amber supported this.
Describe the solution you'd like
Since we already use the
clap
library, we can use the complementaryclap_complete
library to do this.Describe alternatives you've considered
N/A
Additional context
See https://docs.rs/clap_complete/latest/clap_complete/ for more details.
The text was updated successfully, but these errors were encountered: