Vix.cpp v2.6.0 is here Read the blog
Skip to content

vix completion

vix completion generates a shell completion script for the Vix CLI.

Use it when you want your shell to autocomplete Vix commands.

Usage

bash
vix completion
vix completion bash
1
2

Both commands generate Bash completion.

What it does

vix completion prints a shell completion script to standard output.

You can either load it for the current terminal session or save it to a file and source it from your shell configuration.

The generated completion script currently supports:

  • top-level Vix commands
  • vix help <command> completion
  • Bash completion through the complete builtin

Supported shells

ShellStatus
BashSupported
ZshNot supported yet
FishNot supported yet
PowerShellNot supported yet

The documented target is:

bash
vix completion bash
1

Calling vix completion without a shell also generates Bash completion.

Basic usage

Generate and load completion for the current shell session:

bash
vix completion bash > ~/.vix-completion.bash
source ~/.vix-completion.bash
1
2

Then try:

bash
vix <Tab>
1

You should see available Vix commands.

One-time usage

Use this when you only want completion for the current terminal session:

bash
source <(vix completion bash)
1

This is temporary.

When you close the terminal, the completion is gone.

Persistent Bash setup

Use this to enable Vix completion every time you open a Bash terminal:

bash
vix completion bash > ~/.vix-completion.bash
echo 'source ~/.vix-completion.bash' >> ~/.bashrc
source ~/.bashrc
1
2
3

After that, open a new terminal and try:

bash
vix <Tab>
1

Safer persistent setup

If you want to avoid adding the same line several times to ~/.bashrc, use:

bash
vix completion bash > ~/.vix-completion.bash

grep -qxF 'source ~/.vix-completion.bash' ~/.bashrc || \
  echo 'source ~/.vix-completion.bash' >> ~/.bashrc

source ~/.bashrc
1
2
3
4
5
6

System-wide Bash setup

If you want to install completion for all users on a Linux system, you can write it to the Bash completion directory:

bash
vix completion bash | sudo tee /etc/bash_completion.d/vix > /dev/null
1

Then start a new shell.

This requires Bash completion support to be installed on the system.

Update completions after upgrading Vix

The completion script is generated from the commands registered in the Vix CLI.

After upgrading Vix, regenerate the completion file:

bash
vix upgrade
vix completion bash > ~/.vix-completion.bash
source ~/.bashrc
1
2
3

This makes sure newly added commands can appear in completion.

How command completion works

The generated Bash script defines a _vix_completions function.

At the first command position, it completes available Vix commands:

bash
vix <Tab>
1

It also completes command names after vix help:

bash
vix help <Tab>
1

The command list is collected from the Vix command dispatcher at generation time.

That means the generated file reflects the installed Vix binary that produced it.

Current behavior

The current completion implementation focuses on top-level commands.

It does not yet complete every option of every subcommand.

For example, it can help with:

bash
vix bu<Tab>
vix he<Tab>
vix help bu<Tab>
1
2
3

But it does not yet provide deep option completion such as:

bash
vix build --pr<Tab>
vix run --sa<Tab>
vix registry sy<Tab>
1
2
3

Those can be added later when command-specific completion metadata is available.

Basic workflows

bash
# Print Bash completion script
vix completion bash

# Save completion script
vix completion bash > ~/.vix-completion.bash

# Load completion in current shell
source ~/.vix-completion.bash

# Install persistent completion
vix completion bash > ~/.vix-completion.bash
echo 'source ~/.vix-completion.bash' >> ~/.bashrc
source ~/.bashrc

# Regenerate after upgrading Vix
vix upgrade
vix completion bash > ~/.vix-completion.bash
source ~/.bashrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Common mistakes

Forgetting to source the generated file

This only writes the script:

bash
vix completion bash > ~/.vix-completion.bash
1

You still need to load it:

bash
source ~/.vix-completion.bash
1

Expecting completion to persist automatically

This only works for the current terminal:

bash
source <(vix completion bash)
1

For persistent completion, add it to ~/.bashrc:

bash
echo 'source ~/.vix-completion.bash' >> ~/.bashrc
1

Forgetting to regenerate after upgrade

If you upgrade Vix and new commands were added, regenerate the completion file:

bash
vix completion bash > ~/.vix-completion.bash
1

Using an unsupported shell target

This is supported:

bash
vix completion bash
1

This is not supported yet:

bash
vix completion zsh
vix completion fish
vix completion powershell
1
2
3

Unsupported shells return an error.

Troubleshooting

Completion does not work

First, confirm that the completion file exists:

bash
ls ~/.vix-completion.bash
1

Then source it again:

bash
source ~/.vix-completion.bash
1

Try completion:

bash
vix <Tab>
1

Bash completion is not installed

On some Linux systems, Bash completion support may not be loaded by default.

Install it using your system package manager.

Ubuntu or Debian:

bash
sudo apt install bash-completion
1

Then restart your terminal.

Completion file is outdated

Regenerate it:

bash
vix completion bash > ~/.vix-completion.bash
source ~/.bashrc
1
2
CommandPurpose
vix --helpShow global CLI help
vix help <command>Show help for a specific command
vix infoInspect Vix paths and local state
vix doctorCheck environment health
vix upgradeUpgrade Vix
vix commandsOpen the command overview

Next step

Return to the command overview.

Open all CLI commands

Released under the MIT License.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.