File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -202,3 +202,51 @@ viam --help
202202viam machines --help
203203viam machines part shell --help
204204```
205+
206+ ## Enable shell completion
207+
208+ The CLI supports tab completion for commands, subcommands, and flag names.
209+ To enable it, source the completion script for your shell.
210+
211+ {{< tabs >}}
212+ {{% tab name="bash" %}}
213+
214+ Add to your ` ~/.bashrc ` :
215+
216+ ``` sh {class="command-line" data-prompt="$"}
217+ source <( viam completion bash)
218+ ```
219+
220+ {{% /tab %}}
221+ {{% tab name="zsh" %}}
222+
223+ Add to your ` ~/.zshrc ` :
224+
225+ ``` sh {class="command-line" data-prompt="$"}
226+ source <( viam completion zsh)
227+ ```
228+
229+ {{% /tab %}}
230+ {{% tab name="fish" %}}
231+
232+ ``` sh {class="command-line" data-prompt="$"}
233+ viam completion fish > ~ /.config/fish/completions/viam.fish
234+ ```
235+
236+ {{% /tab %}}
237+ {{% tab name="PowerShell" %}}
238+
239+ ``` powershell {class="command-line" data-prompt=">"}
240+ viam completion pwsh | Out-String | Invoke-Expression
241+ ```
242+
243+ {{% /tab %}}
244+ {{< /tabs >}}
245+
246+ After sourcing the script, press ** Tab** to complete commands and flags:
247+
248+ ``` sh {class="command-line" data-prompt="$"}
249+ viam < Tab> # lists all commands
250+ viam machines < Tab> # lists subcommands of machines
251+ viam data export < Tab> # lists subcommands of export
252+ ```
Original file line number Diff line number Diff line change @@ -19,6 +19,28 @@ viam [global options] command [command options] [arguments...]
1919
2020## Commands
2121
22+ ### ` completion `
23+
24+ The ` completion ` command outputs a shell completion script.
25+ Source the output in your shell to enable tab completion for commands, subcommands, and flag names.
26+
27+ ``` sh {class="command-line" data-prompt="$"}
28+ viam completion bash
29+ viam completion zsh
30+ viam completion fish
31+ viam completion pwsh
32+ ```
33+
34+ <!-- prettier-ignore -->
35+ | Argument | Description |
36+ | -------- | ----------- |
37+ | ` bash ` | Output a bash completion script. |
38+ | ` zsh ` | Output a zsh completion script. |
39+ | ` fish ` | Output a fish completion script. |
40+ | ` pwsh ` | Output a PowerShell completion script. |
41+
42+ For setup instructions, see [ Enable shell completion] ( /cli/overview/#enable-shell-completion ) .
43+
2244### ` data `
2345
2446The ` data ` command allows you to manage machine data.
You can’t perform that action at this time.
0 commit comments