Skip to main content

Adding Command-Line Completion

The Kurtosis CLI supports command-line completion for bash, zsh, and fish. With completion installed, you will be able to:

  • Complete subcommands (e.g. typing kurtosis and pressing TAB will suggest subcommands)
  • Complete dynamic arguments (e.g. typing kurtosis enclave inspect and pressing TAB will list the names of existing enclaves if any)

The process for installing completion is specific to each shell:

  1. Print your Bash version:
    bash --version
  2. If your Bash version is less than 4.1, upgrade it:
  3. Check if you have bash-completion installed:
    type _init_completion
  4. If you get an error like -bash: type: _init_completion: not found, install Bash completion:
    • On Mac:
      1. Install the completion library:
        brew install bash-completion@2
      2. Add the following to your ~/.bash_profile:
        export BREW_PREFIX="$(brew --prefix)"
        [[ -r "${BREW_PREFIX}/etc/profile.d/bash_completion.sh" ]] && source "${BREW_PREFIX}/etc/profile.d/bash_completion.sh"
      3. Close and re-open your terminal window to reload your shell.
      4. Verify that you now have the completion installed:
        type _init_completion
    • On Linux, install it using the package manager for your distro using these installation instructions
  5. Skip this step if you are installing using Homebrew and have bash-completion@2 installed. Otherwise, proceed to source the output of kurtosis completion bash in your Bash config file:
    • On Mac, add the following to your ~/.bash_profile file:
      # Add Kurtosis command-line completion
      source <(kurtosis completion bash)
    • On Linux, add the following to your ~/.bashrc file:
      # Add Kurtosis command-line completion
      source <(kurtosis completion bash)
  6. If you have an alias set up for Kurtosis, add completion for that as well (we'll assume the alias kt in the examples below):
    • On Mac, add the following to your ~/.bash_profile file:
      # Add command-line completion to Kurtosis alias
      complete -F __start_kurtosis kt
    • On Linux, add the following to your ~/.bashrc file:
      # Add command-line completion to Kurtosis alias
      complete -F __start_kurtosis kt
  7. Close and re-open your terminal window to reload your shell and apply the changes.