shell completions#
Description#
The completion
command generates shell completions for bash/zsh/fish shells.
All command line arguments can be also provided via environment variables (CLI flags take precedence). The environment variable names are constructed by prepending
CLAB_
to the flag name, then adding the command path and ending with the flag name in its full form, all in uppercase and with hyphens replaced by underscores.For example, the
--max-workers
flag for thedeploy
command can be set viaCLAB_DEPLOY_MAX_WORKERS
environment variable.
OrCLAB_INSPECT_ALL=1
to set--all
flag for theinspect
command.
OrCLAB_TOPO=srlinux.dev/clab-srl clab dep -c
to deploy a lab with the topology passed via environment variable.
Usage#
containerlab completion [arg]
Bash completions#
Ensure that bash-completion is installed on your system.
To load completions for the current session:
To load completions for each session:
To also autocomplete for clab
command alias, add the following to your .bashrc
or .bash_profile
:
ZSH completions#
If shell completion is not already enabled in your environment you have to enable it by ensuring zsh completions are loaded. The following can be added to your zshrc:
To load completions for each session generate the completion script and store it somewhere in your $fpath
:
clab completion zsh | \
sed '1,2c\#compdef containerlab clab\ncompdef _containerlab containerlab clab' > \
~/.oh-my-zsh/custom/completions/_containerlab
Completion script location
The example above uses the ~/.oh-my-zsh/custom/completions
directory, which might not exist by default.
echo $fpath
will show the directories zsh reads files from. You can either use one of the available completions directories from this list or add a new directory:
and then add this directory to the fpath
list by adding it in your .zshrc file:
Now you can use ~/.oh-my-zsh/custom/completions
for your completions as shown above.
Start a new shell for this setup to take effect.
Fish completions#
To load clab
and containerlab
completions for each session, execute once: