|
| 1 | +--- |
| 2 | +# SPDX-FileCopyrightText: the secureCodeBox authors |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: Apache-2.0 |
| 5 | + |
| 6 | +title: "Setup Shell completion" |
| 7 | +description: "How to shell completion and leverage scbctl shell completion" |
| 8 | +sidebar_position: 3 |
| 9 | +--- |
| 10 | + |
| 11 | +# Setting Up Shell Completion for scbctl |
| 12 | + |
| 13 | +Shell completion is a feature that allows scbctl to automatically complete command names, flags, and arguments as you type them in your terminal. This can significantly improve your productivity and ease of use when working with scbctl. |
| 14 | + |
| 15 | +## Supported Shells |
| 16 | + |
| 17 | +scbctl supports shell completion for the following shells: |
| 18 | +- Bash |
| 19 | +- Zsh |
| 20 | +- Fish |
| 21 | +- PowerShell |
| 22 | + |
| 23 | +## General Setup |
| 24 | + |
| 25 | +To view the shell completion setup instructions, use the following command: |
| 26 | + |
| 27 | +```bash |
| 28 | +scbctl completion --help |
| 29 | +``` |
| 30 | + |
| 31 | +This will display usage information and examples for different shells. |
| 32 | + |
| 33 | +## Bash Completion Setup |
| 34 | + |
| 35 | +1. Ensure that bash-completion is installed. If not, you can install it using your package manager: |
| 36 | + |
| 37 | + ```bash |
| 38 | + # For Ubuntu/Debian |
| 39 | + sudo apt-get install bash-completion |
| 40 | + |
| 41 | + # For macOS (using Homebrew) |
| 42 | + brew install bash-completion |
| 43 | + ``` |
| 44 | + |
| 45 | +2. Add the following line to your `~/.bashrc` file: |
| 46 | + |
| 47 | + ```bash |
| 48 | + source <(scbctl completion bash) |
| 49 | + ``` |
| 50 | + |
| 51 | +3. Reload your shell or run: |
| 52 | + |
| 53 | + ```bash |
| 54 | + source ~/.bashrc |
| 55 | + ``` |
| 56 | + |
| 57 | +## Zsh Completion Setup |
| 58 | + |
| 59 | +1. Add the following line to your `~/.zshrc` file: |
| 60 | + |
| 61 | + ```zsh |
| 62 | + source <(scbctl completion zsh) |
| 63 | + ``` |
| 64 | + |
| 65 | +2. If you get an error like `complete:13: command not found: compdef`, add the following to the beginning of your `~/.zshrc` file: |
| 66 | + |
| 67 | + ```zsh |
| 68 | + autoload -Uz compinit |
| 69 | + compinit |
| 70 | + ``` |
| 71 | + |
| 72 | +3. Reload your shell or run: |
| 73 | + |
| 74 | + ```zsh |
| 75 | + source ~/.zshrc |
| 76 | + ``` |
| 77 | + |
| 78 | +## Fish Completion Setup |
| 79 | + |
| 80 | +1. Run the following command: |
| 81 | + |
| 82 | + ```fish |
| 83 | + scbctl completion fish | source |
| 84 | + ``` |
| 85 | + |
| 86 | +2. To make it permanent, append the above command to your `~/.config/fish/config.fish` file: |
| 87 | + |
| 88 | + ```fish |
| 89 | + echo "scbctl completion fish | source" >> ~/.config/fish/config.fish |
| 90 | + ``` |
| 91 | + |
| 92 | +## PowerShell Completion Setup |
| 93 | + |
| 94 | +1. Create a new file named `scbctl_completion.ps1` in your PowerShell profile directory: |
| 95 | + |
| 96 | + ```powershell |
| 97 | + scbctl completion powershell > $HOME\Documents\WindowsPowerShell\scbctl_completion.ps1 |
| 98 | + ``` |
| 99 | + |
| 100 | +2. Add the following line to your PowerShell profile: |
| 101 | + |
| 102 | + ```powershell |
| 103 | + . $HOME\Documents\WindowsPowerShell\scbctl_completion.ps1 |
| 104 | + ``` |
| 105 | + |
| 106 | + |
| 107 | +## Verifying Completion Setup |
| 108 | + |
| 109 | +After setting up completion, you can verify it's working by: |
| 110 | + |
| 111 | +1. Starting a new shell session or reloading your current one. |
| 112 | +2. Typing `scbctl` followed by a space and then pressing the Tab key. |
| 113 | +3. You should see available commands or options auto-completed or listed. |
| 114 | + |
| 115 | +## Troubleshooting |
| 116 | + |
| 117 | +If completion doesn't work after following these steps: |
| 118 | + |
| 119 | +1. Ensure you've reloaded your shell or started a new session. |
| 120 | +2. Check that scbctl is in your system's PATH. |
| 121 | +3. Verify that you've correctly added the completion command to your shell's configuration file. |
| 122 | +4. For Bash and Zsh, make sure you have the required completion utilities installed. |
0 commit comments