From f13f49ebbfab311660b13abadb26f87fc099377e Mon Sep 17 00:00:00 2001 From: Munif Tanjim Date: Tue, 26 May 2020 20:07:15 +0600 Subject: [PATCH] Add CLI shell completion documentation (#112) * Add CLI shell completion documentation * Update cli.md Co-authored-by: Kyle Spearrin --- _articles/miscellaneous/cli.md | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/_articles/miscellaneous/cli.md b/_articles/miscellaneous/cli.md index 1d4d8a48..3ed06a5a 100644 --- a/_articles/miscellaneous/cli.md +++ b/_articles/miscellaneous/cli.md @@ -45,6 +45,8 @@ Bitwarden provides a powerful, full-featured command-line interface (CLI) tool t - [Version](#version) - [Working with JSON](#working-with-json) - [Self-signed Certificates](#self-signed-certificates) +- [Shell Completion](#shell-completion) + - [ZSH](#zsh) - [Source Code](#source-code) - [Appendix](#appendix) - [Templates](#templates) @@ -427,6 +429,40 @@ If your self-hosted Bitwarden server exposes as self-signed TLS certificate, spe $env:NODE_EXTRA_CA_CERTS="absolute/path/to/your/certificates.pem" + +## Shell Completion + +Bitwarded CLI comes with support for shell completion. It can generate shell completion scripts that you can use to enable completion for `bw` in your shell. + +### ZSH + +You can enable `bw` completion for ZSH using various methods. A few of them are mentioned below: + +**vanilla (.zshrc)**: + +Add the following line in your `.zshrc` file: + +``` +eval "$(bw completion --shell zsh); compdef _bw bw;" +``` + +**vanilla (vendor-completions)**: + +Run the following command: + +``` +bw completion --shell zsh | sudo tee /usr/share/zsh/vendor-completions/_bw +``` + +[**zinit**](https://github.com/zdharma/zinit): + +Run the following commands: + +``` +bw completion --shell zsh > ~/.local/share/zsh/completions/_bw +zinit creinstall ~/.local/share/zsh/completions +``` + ## Source Code As with everything here at Bitwarden, the CLI is fully open source and hosted on GitHub at .