|
| 1 | +# Command line completion |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +## Installing completion |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +Install [Carapace](https://carapace.sh/) for your platform: |
| 10 | + |
| 11 | +**macOS:** |
| 12 | + |
| 13 | +```bash |
| 14 | +brew install carapace |
| 15 | +``` |
| 16 | + |
| 17 | +**Ubuntu/Debian:** |
| 18 | + |
| 19 | +```bash |
| 20 | +sudo apt install carapace-bin |
| 21 | +``` |
| 22 | + |
| 23 | +**Windows:** |
| 24 | + |
| 25 | +```powershell |
| 26 | +winget install carapace |
| 27 | +``` |
| 28 | + |
| 29 | +For other platforms, see the [Carapace installation guide](https://carapace-sh.github.io/carapace-bin/install.html). |
| 30 | + |
| 31 | +### Enable Carapace completion for Serverpod |
| 32 | + |
| 33 | +#### Bash |
| 34 | + |
| 35 | +Install the completion spec: |
| 36 | + |
| 37 | +```bash |
| 38 | +serverpod completion install --tool carapace |
| 39 | +``` |
| 40 | + |
| 41 | +Then add the following to your `~/.bashrc` to enable Carapace: |
| 42 | + |
| 43 | +```bash |
| 44 | +source <(carapace _carapace) |
| 45 | +``` |
| 46 | + |
| 47 | +Restart your shell or run `source ~/.bashrc` to apply. |
| 48 | + |
| 49 | +#### Zsh |
| 50 | + |
| 51 | +Install the completion spec: |
| 52 | + |
| 53 | +```bash |
| 54 | +serverpod completion install --tool carapace |
| 55 | +``` |
| 56 | + |
| 57 | +Then add the following to your `~/.zshrc` to enable Carapace: |
| 58 | + |
| 59 | +```bash |
| 60 | +zstyle ':completion:*' format $'\e[2;37mCompleting %d\e[m' |
| 61 | +source <(carapace _carapace) |
| 62 | +``` |
| 63 | + |
| 64 | +Restart your shell or run `source ~/.zshrc` to apply. |
| 65 | + |
| 66 | +#### Other shells |
| 67 | + |
| 68 | +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. |
| 69 | + |
| 70 | +## Alternative: Completely |
| 71 | + |
| 72 | +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. |
| 73 | + |
| 74 | +To generate a Completely spec and create a completion script: |
| 75 | + |
| 76 | +```bash |
| 77 | +serverpod completion generate --tool completely -f serverpod.yaml |
| 78 | +completely generate serverpod.yaml serverpod.bash |
| 79 | +``` |
| 80 | + |
| 81 | +Then source the generated script in your shell config (e.g., `source /path/to/serverpod.bash` in `~/.bashrc` or `~/.zshrc`). |
| 82 | + |
| 83 | +:::note |
| 84 | +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. |
| 85 | +::: |
0 commit comments