Skip to main content
Version: 0.68.5

Adding Tab Completion

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

  • Tab-complete subcommands (e.g. typing kurtosis and pressing TAB will suggest subcommands)
  • Tab-complete dynamic arguments, when possible (e.g. typing kurtosis enclave inspect and pressing TAB will try to complete with the current enclave IDs)

The process for installing tab completion is specific to each shell:

bash
  1. Ensure you have Bash version >= 4.1
    1. Print your Bash version:
      echo $BASH_VERSION
    2. If your Bash version is less than 4.1, upgrade it:
  2. Check if you have bash-completion installed:
    type _init_completion
  3. 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. 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
  4. 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 tab-completion
      source <(kurtosis completion bash)
    • On Linux, add the following to your ~/.bashrc file:
      # Add Kurtosis tab-completion
      source <(kurtosis completion bash)
  5. 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 tab-completion to Kurtosis alias
      complete -F __start_kurtosis kt
    • On Linux, add the following to your ~/.bashrc file:
      # Add tab-completion to Kurtosis alias
      complete -F __start_kurtosis kt
  6. Reload your shell
zsh
  1. Add the following to your ~/.zshrc file:
    # Add Kurtosis tab-completion
    source <(kurtosis completion zsh)
    compdef _kurtosis kurtosis
  2. If you have an alias set up for Kurtosis, add the following to your ~/.zshrc file (we'll assume the alias kt in this example):
    # Add tab-completion to Kurtosis alias
    compdef __start_kurtosis kt
  3. Reload your shell
  4. If you get an error like complete:13: command not found: compdef, add the following to the top of your ~/.zshrc and reload your shell again:
    autoload -Uz compinit
    compinit
fish
  1. Add the following to your ~/.config/fish/config.fish file:
    # Add Kurtosis tab-completion
    kurtosis completion fish | source
  2. Reload your shell
manual installation

If necessary, tab completion can be installed manually in two steps as follows, by first generating the tab completion code (specific to the shell) and then sourcing that code into the shell.

  1. The code needed to enable tab completion can be generated by the kurtosis cli by running kurtosis completion <SHELL> command, e.g. for bash:

    kurtosis completion bash 
  2. sourceing the output of the command will enable tab-completion, and adding the source command to your shell config file will enable it across shell instances.

    # Add Kurtosis tab-completion to your shell config file
    source <(kurtosis completion bash)