Autocomplete

Fig Autocomplete

In order to give a better experience for terminal users, we support the Fig Auto-complete.

Unlike other auto-complete tools, Fig is more intuitive. It brings an IDE-style experience to the terminal users. Detailed introduction see the official website

Autocomplete - 图1

Notice: Temporary only supports MacOS now!

Setup

See https://fig.io

Autocomplete - 图2

Once the installation is complete, you need to integrate the terminal you are using.

Examples

Get Specified Plugin Information

Autocomplete - 图3

Get Subcommand Help Information

Autocomplete - 图4

Build a Specified Plugin

Autocomplete - 图5

Shell Autocomplete

Bash Autocompletion

On Linux

Note: Main reference bash auto-completion on Linux

The completion script depends on bash-completion, So you have to install it first.

Bash

  1. apt-get install bash-completion # For Ubuntu
  2. yum install bash-completion # For CentOS and RedHat

The above commands create /usr/share/bash-completion/bash_completion, which is the main script of bash-completion. Depending on your package manager, you have to manually source this file in your ~/.bashrc file.

To find out, reload your shell and run type _init_completion. If the command succeeds, you’re already set, otherwise add the following to your ~/.bashrc file:

Bash

  1. source /usr/share/bash-completion/bash_completion

Reload your shell and verify that bash-completion is correctly installed by typing type _init_completion.

Then You can generate completion script for Bash with the command dtm completion bash and add the following line to your ~/.bashrc file. You can execute the following command to add it automatically.

Bash

  1. echo 'source <(dtm completion bash)' >>~/.bashrc
  2. source ~/.bashrc

After reloading your shell, dtm autocompletion should be working!

On MacOS

```{admonition} Note :class: note Main reference bash auto-completion on macOS

Text Only

  1. The completion script depends on `bash-completion`, So you have to install it first.
  2. ```bash
  3. brew install bash-completion@2

As stated in the output of this command, add the following to your ~/.bash_profile file:

Bash

  1. brew_etc="$(brew --prefix)/etc"
  2. echo "[[ -r \"${brew_etc}/profile.d/bash_completion.sh\" ]] && . \"${brew_etc}/profile.d/bash_completion.sh\"" >>~/.bash_profile
  3. source ~/.bash_profile

Reload your shell and verify that bash-completion v2 is correctly installed with type _init_completion.

Then You can generate completion script for Bash with the command dtm completion bash and add the following to your ~/.bash_profile file. You can execute the following command to add it automatically.

Bash

  1. echo 'source <(dtm completion bash)' >>~/.bash_profile

After reloading your shell, dtm autocompletion should be working!

Zsh Autocompletion

You can generate completion script for Zsh with the command dtm completion zsh. Then add the following line to your ~/.zshrc file. You can execute the following command to add it automatically.

Bash

  1. echo 'source <(dtm completion zsh)' >>~/.zshrc

After reloading your shell, dtm autocompletion should be working!

Fish Autocompletion

You can generate completion script for Fish with the command dtm completion fish.Then add the following line to your ~/.config/fish/config.fish file:

Fish

  1. dtm completion fish | source

After reloading your shell, dtm autocompletion should be working!

PowerShell Autocompletion

You can generate completion script for PowerShell with the command dtm completion powershell. Then add the following line to your $PROFILE file:

PowerShell

  1. dtm completion powershell | Out-String | Invoke-Expression

This command will regenerate the auto-completion script on every PowerShell start up. You can also add the generated script directly to your $PROFILE file.

To add the generated script to your $PROFILE file, run the following line in your powershell prompt:

PowerShell

  1. dtm completion powershell >> $PROFILE

After reloading your shell, dtm autocompletion should be working.