Skip to content

Latest commit

 

History

History
141 lines (120 loc) · 5.45 KB

adding-command-line-completion.md

File metadata and controls

141 lines (120 loc) · 5.45 KB
title sidebar_label sidebar_position
Adding Command-Line Completion
Adding Command-Line Completion
4

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

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.
  1. Add the following to your ~/.zshrc file:
    # Add Kurtosis command-line 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 command-line completion to Kurtosis alias
    compdef __start_kurtosis kt
  3. Close and re-open your terminal window to reload your shell and apply the changes.
  4. If you get an error like complete:13: command not found: compdef, add the following to the top of your ~/.zshrc and close and re-open your terminal window to reload your shell:
    autoload -Uz compinit
    compinit
  1. Add the following to your ~/.config/fish/config.fish file:
    # Add Kurtosis command-line completion
    kurtosis completion fish | source
  2. Close and re-open your terminal window to reload your shell and apply the changes.

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 command-line completion, and adding the source command to your shell config file will enable it across shell instances.

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