-
Notifications
You must be signed in to change notification settings - Fork 486
[doc] Add documentation page explaining shell completion #15403
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| How to Set Up Shell Command Completion | ||
| ====================================== | ||
|
|
||
| Shell command completion refers to a common feature in various shells: | ||
| hitting \<TAB\> after a partially-typed command will print matching suggestions. | ||
| This can apply to command names, flags, arguments, filenames... | ||
|
|
||
| Dune offers completion for commands, subcommands, and flags, for `bash`, `zsh`, and `powershell`. | ||
| The various shells and systems require specific configuration setups, | ||
| and this document aims to help users get completion running. | ||
|
|
||
| Bash | ||
| ---- | ||
|
|
||
| Command completion for bash might require [bash-completion](https://github.com/scop/bash-completion). | ||
| You will then need to create the bash completion script (by running `dune completion bash`) | ||
| and write that script to an appropriate place: by default that should be | ||
| `~/.local/share/bash-completion/completions/dune` for a user-local configuration, | ||
| or `/usr/local/share/bash-completion/completions/dune` for a system-wide installation. | ||
| If you use `opam` switches and wish to have switch-local completion, | ||
| add the script to `<switch prefix>/share/bash-completion/completions/dune`. | ||
|
|
||
| A different path would be to add to your `.bashrc` the following line: `eval "$(dune completion bash)"`. | ||
|
|
||
| You might need to restart your shell to see the effects. | ||
|
|
||
| Zsh | ||
| --- | ||
|
|
||
| Command completion for zsh might require [zsh-completions](https://github.com/zsh-users/zsh-completions). | ||
| You will then need to create the zsh completion script (by running `dune completion zsh`) | ||
| and write that script to a place that will get autoloaded: directories present | ||
| in your `$fpath` (by default it should be `~/.local/share/zsh/site-functions`). | ||
| If you wish to create a dedicated completion directory and add it to your `$fpath`, | ||
| be sure to add the following in your `.zshrc` but **before** any call to `compinit`: | ||
| `fpath+=<your dir>`. | ||
|
|
||
| You might need to restart your shell to see the effects. | ||
|
|
||
| PowerShell | ||
| ---------- | ||
|
|
||
| Command completion for powershell should work out of the box: | ||
| simply run `dune completion powershell >> $PROFILE.CurrentUserCurrentHost`. | ||
| Alternatively, add the following to your profile script: | ||
| `dune completion powershell | Out-String | Invoke-Expression`. | ||
|
|
||
| You might need to restart your shell to see the effects. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is about the one above the alternative, so probably best move it up.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually all of the shells have this same flow issue
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't sure what may or may not require a shell restart, so I added up at the end of each section to be sure
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The eval-like steps don't require a restart, anything editing configuration likely does. I'm certain about bash and powershell but not about zsh.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only true for command names and flags at the moment of writing. Let's not over-promise at this point and be accurate. If this document is stale when we add new completion features that's fine, it can always be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The aim here was to have a first paragraph that is a definition of what the term even means in a general sense, and right after that I specify what dune offers
do you think mentionning filenames here is ambiguous or over-promising?