From 3b5c5fe312c414b99e085ccbcaf555dd75038b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Fabianski?= Date: Fri, 27 Oct 2023 10:28:24 +0200 Subject: [PATCH 1/5] docs: add shell completion to nav.js --- docs/_data/nav.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/_data/nav.js b/docs/_data/nav.js index a00463a73..14a18a88b 100644 --- a/docs/_data/nav.js +++ b/docs/_data/nav.js @@ -44,6 +44,10 @@ module.exports = [ name: "Using Bearer Cloud", url: "/guides/bearer-cloud/", }, + { + name: "Enable shell completion", + url: "/guides/shell-completion/", + }, ], }, { From 75594c2223642d8c3e7c6caca343b1507a249e86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Fabianski?= Date: Fri, 27 Oct 2023 16:32:00 +0200 Subject: [PATCH 2/5] docs: update nav.js We want Bearer Cloud Guide to be the last item --- docs/_data/nav.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/_data/nav.js b/docs/_data/nav.js index 14a18a88b..7df4f5330 100644 --- a/docs/_data/nav.js +++ b/docs/_data/nav.js @@ -40,14 +40,14 @@ module.exports = [ name: "Run a data flow report", url: "/guides/dataflow/", }, - { - name: "Using Bearer Cloud", - url: "/guides/bearer-cloud/", - }, { name: "Enable shell completion", url: "/guides/shell-completion/", }, + { + name: "Using Bearer Cloud", + url: "/guides/bearer-cloud/", + }, ], }, { From 49e5aba53e45d6dd1b3a8c9d189491ffae1f40a5 Mon Sep 17 00:00:00 2001 From: gotbadger Date: Tue, 31 Oct 2023 15:23:25 +0000 Subject: [PATCH 3/5] docs(guides): improve completions guide --- docs/_data/nav.js | 2 +- docs/guides/shell-completion.md | 44 ++++++++++++++------------------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/docs/_data/nav.js b/docs/_data/nav.js index 7df4f5330..3abac8ade 100644 --- a/docs/_data/nav.js +++ b/docs/_data/nav.js @@ -41,7 +41,7 @@ module.exports = [ url: "/guides/dataflow/", }, { - name: "Enable shell completion", + name: "Shell completions", url: "/guides/shell-completion/", }, { diff --git a/docs/guides/shell-completion.md b/docs/guides/shell-completion.md index 9f6c03458..6d7c84426 100644 --- a/docs/guides/shell-completion.md +++ b/docs/guides/shell-completion.md @@ -2,39 +2,42 @@ 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 will be vary depend 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: -Generate the autocompletion script for the zsh shell. +```bash +source <(bearer completion zsh); compdef _bearer bearer +``` -If shell completion is not already enabled in your environment you will need -to enable it. You can execute the following once: +Now you can test completions: ```bash -echo "autoload -U compinit; compinit" >> ~/.zshrc +bearer [tab] ``` -To load completions in your current shell session: +**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 -source <(bearer completion zsh); compdef _bearer bearer +echo "autoload -U compinit; compinit" >> ~/.zshrc ``` -To load completions for every new session, execute once: +## Final setup + +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: ### Linux @@ -50,14 +53,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] -``` From dffd398d9b3e6d2f9140e97cafdb62d511b255cb Mon Sep 17 00:00:00 2001 From: Philip Hayton Date: Tue, 31 Oct 2023 16:27:44 +0000 Subject: [PATCH 4/5] Apply suggestions from code review Co-authored-by: elsapet --- docs/guides/shell-completion.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guides/shell-completion.md b/docs/guides/shell-completion.md index 6d7c84426..ceb676594 100644 --- a/docs/guides/shell-completion.md +++ b/docs/guides/shell-completion.md @@ -4,7 +4,7 @@ title: Enable Completion Script # Enabling shell completions -Completions make it easier to use bearer on the command line. In this guide we will cover how to set everything up. +Completions make it easier to use Bearer on the command line. In this guide we will cover how to set everything up. ## Discover your current shell @@ -12,7 +12,7 @@ Completions make it easier to use bearer on the command line. In this guide we w $ echo $SHELL /bin/zsh ``` -In our example it's zsh, but will be vary depend on your $SHELL. +In our example it's zsh, but this will vary depending on your $SHELL. ## Test the completion scripts From 9334b76543354475797808e3da57aeb00a51a2f0 Mon Sep 17 00:00:00 2001 From: gotbadger Date: Tue, 31 Oct 2023 16:31:39 +0000 Subject: [PATCH 5/5] docs: completion guide feedback --- docs/guides/shell-completion.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/docs/guides/shell-completion.md b/docs/guides/shell-completion.md index ceb676594..30cc53e43 100644 --- a/docs/guides/shell-completion.md +++ b/docs/guides/shell-completion.md @@ -22,11 +22,7 @@ We currently support `zsh` `bash` and `fish`. To load completions in your curren source <(bearer completion zsh); compdef _bearer bearer ``` -Now you can test completions: - -```bash -bearer [tab] -``` +Now you can test completions. Type `bearer` into your terminal and hit the tab button on your keyboard. **Note:** if completions are not already enabled in your environment you will need to enable it. In zsh you can execute the following once: