Skip to content
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

docs: add shell completion to nav.js #1357

Merged
merged 5 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/_data/nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ module.exports = [
name: "Run a data flow report",
url: "/guides/dataflow/",
},
{
name: "Shell completions",
url: "/guides/shell-completion/",
},
{
name: "Using Bearer Cloud",
url: "/guides/bearer-cloud/",
Expand Down
42 changes: 15 additions & 27 deletions docs/guides/shell-completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,38 @@
title: Enable Completion Script
---

# Enable shell completion
# Enabling shell completions

Below is example steps to enable shell completion feature for `bearer` cli:
Completions make it easier to use Bearer on the command line. In this guide we will cover how to set everything up.

## 1. Know your current shell
## Discover your current shell

```bash
$ echo $SHELL
/bin/zsh # For this example it is zsh, but will be vary depend on your $SHELL, maybe /bin/bash or /bin/fish
/bin/zsh
```
In our example it's zsh, but this will vary depending on your $SHELL.

## 2. Run `completion` command to get sub-commands
## Test the completion scripts

``` bash
bearer completion -h
We currently support `zsh` `bash` and `fish`. To load completions in your current shell session you can run the following:

```bash
source <(bearer completion zsh); compdef _bearer bearer
```

Generate the autocompletion script for the zsh shell.
Now you can test completions. Type `bearer` into your terminal and hit the tab button on your keyboard.

If shell completion is not already enabled in your environment you will need
to enable it. You can execute the following once:
**Note:** if completions are not already enabled in your environment you will need
to enable it. In zsh you can execute the following once:

```bash
echo "autoload -U compinit; compinit" >> ~/.zshrc
```

To load completions in your current shell session:

```bash
source <(bearer completion zsh); compdef _bearer bearer
```
## Final setup

To load completions for every new session, execute once:
To load completions for every new session you can add the test command to your `~/.zshrc` or similar. Alternatively if you are using zsh you can execute the following once:
gotbadger marked this conversation as resolved.
Show resolved Hide resolved

### Linux

Expand All @@ -50,14 +49,3 @@ bearer completion zsh > $(brew --prefix)/share/zsh/site-functions/_bearer

You will need to start a new shell for this setup to take effect.

## 3. Run the sub-commands following the instruction

```bash
bearer completion zsh > "${fpath[1]}/_bearer"
```

## 4. Start a new shell and you can see the shell completion

```bash
bearer [tab]
```
Loading