-
Notifications
You must be signed in to change notification settings - Fork 82
docs: Added documentation on cli shell autocompletion integration. #427
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
Open
FXschwartz
wants to merge
4
commits into
serverpod:main
Choose a base branch
from
FXschwartz:cli-autocomplete
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c63adc5
Added documentation on cli autocomplete integration.
FXschwartz ee990e6
Updated title to be proper case.
FXschwartz a509e64
Fixed some inconsistent explanations.
FXschwartz 69840d4
Added completely section. Added linux and windows examples.
FXschwartz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Command line completion | ||
|
|
||
| As a `serverpod` user, you can enable command line completion in most shells. The Serverpod CLI supports completion through [Carapace](https://carapace.sh/), which provides tab-completion for commands, options, and their values in bash, zsh, fish, PowerShell, and more. | ||
|
|
||
| ## Installing completion | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| Install [Carapace](https://carapace.sh/) for your platform: | ||
|
|
||
| **macOS:** | ||
|
|
||
| ```bash | ||
| brew install carapace | ||
| ``` | ||
|
|
||
| **Ubuntu/Debian:** | ||
|
|
||
| ```bash | ||
| sudo apt install carapace-bin | ||
| ``` | ||
|
|
||
| **Windows:** | ||
|
|
||
| ```powershell | ||
| winget install carapace | ||
| ``` | ||
|
|
||
| For other platforms, see the [Carapace installation guide](https://carapace-sh.github.io/carapace-bin/install.html). | ||
|
|
||
| ### Enable Carapace completion for Serverpod | ||
|
|
||
| #### Bash | ||
|
|
||
| Install the completion spec: | ||
|
|
||
| ```bash | ||
| serverpod completion install --tool carapace | ||
| ``` | ||
|
|
||
| Then add the following to your `~/.bashrc` to enable Carapace: | ||
|
|
||
| ```bash | ||
| source <(carapace _carapace) | ||
| ``` | ||
|
|
||
| Restart your shell or run `source ~/.bashrc` to apply. | ||
|
|
||
| #### Zsh | ||
|
|
||
| Install the completion spec: | ||
|
|
||
| ```bash | ||
| serverpod completion install --tool carapace | ||
| ``` | ||
|
|
||
| Then add the following to your `~/.zshrc` to enable Carapace: | ||
|
|
||
| ```bash | ||
| zstyle ':completion:*' format $'\e[2;37mCompleting %d\e[m' | ||
| source <(carapace _carapace) | ||
FXschwartz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| Restart your shell or run `source ~/.zshrc` to apply. | ||
|
|
||
| #### Other shells | ||
|
|
||
| Carapace supports fish, PowerShell, elvish, and more. After installing the completion spec with `serverpod completion install --tool carapace`, see the [Carapace setup documentation](https://carapace-sh.github.io/carapace-bin/setup.html) for instructions specific to your shell. | ||
|
|
||
| ## Alternative: Completely | ||
|
|
||
| The Serverpod CLI also supports [Completely](https://github.com/bashly-framework/completely), a lightweight alternative to Carapace that supports bash and zsh. Unlike Carapace, Completely does not require a separate tool running in your shell — it generates a standalone bash completion script. | ||
|
|
||
| To generate a Completely spec and create a completion script: | ||
|
|
||
| ```bash | ||
| serverpod completion generate --tool completely -f serverpod.yaml | ||
| completely generate serverpod.yaml serverpod.bash | ||
| ``` | ||
|
|
||
| Then source the generated script in your shell config (e.g., `source /path/to/serverpod.bash` in `~/.bashrc` or `~/.zshrc`). | ||
|
|
||
| :::note | ||
| Carapace is the recommended tool as it supports a wider range of shells and comes with a pre-built completion spec that can be installed directly with `serverpod completion install`. Completely requires generating and processing the script manually. | ||
| ::: | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.