You are viewing an older version of this section. View current production version.
Toolbox Command Auto-Completion
As of Toolbox 1.6.6, the [Tab] key can be used to auto-complete Toolbox commands in both the bash
and zsh
shells when Toolbox is installed via .rpm
and .deb
packages, as well as via tarball with some additional configuration.
The bash-completion
package must be installed on a host that has SSH access to all hosts in the cluster. Typically, this is the Master Aggregator host.
Toolbox is installed when deploying a new self-managed cluster, or may be installed manually, typically on the cluster’s Master Aggregator host.
Install bash-completion
-
Determine if the
bash-completion
package is installed.Red Hat Distributions
sudo yum list installed | grep bash-completion **** bash-completion.noarch 1:2.1-8.el7 @base libvirt-bash-completion.x86_64 4.5.0-36.el7_9.3 @updates
Debian Distributions
sudo dpkg-query --list | grep bash-completion **** ii bash-completion 1:2.10-1ubuntu1 all programmable completion for the bash shell
-
If
bash-completion
is not installed or is earlier than version 2.7, install the latestbash-completion
package.Red Hat Distributions
sudo yum install bash-completion
Debian Distributions
sudo apt install bash-completion
Copy the Auto-Completion Script
This step is only required for tarball-based Toolbox installs. If Toolbox has been installed using .deb
or .rpm
packages, skip this step.
-
Copy the Toolbox auto-completion script to the
/etc/bash_completion.d
directory.sudo cp <path-to-toolbox>/sdb-autocomplete/bash-completion-sdb-tools /etc/bash_completion.d/
where
<path-to-toolbox>
is the full path to the folder that contains the Toolbox binaries (the folder that is created when the Toolbox.tar.gz
file is extracted).
Configure Your Shell
This section demonstrates how to configure bash
and zsh
shells to enable the Toolbox auto-completion feature for terminal sessions.
bash
You may use this feature by manually sourcing the bash-completion-sdb-tools
file in each new terminal session.
source /etc/bash_completion.d/bash-completion-sdb-tools
To automatically enable this feature in each new terminal session:
-
Add the following command to your shell profile, such as the
~/.bashrc
file, or the~/.bash_profile
file.echo "source /etc/bash_completion.d/bash-completion-sdb-tools" >> ~/.bashrc
– or –
echo "source /etc/bash_completion.d/bash-completion-sdb-tools" >> ~/.bash_profile
-
This feature is now enabled for each new terminal session. For those terminal sessions that are already open, source your shell profile to use this feature.
source ~/.bashrc
– or –
source ~/.bash_profile
zsh
To automatically enable this feature in each new terminal session:
-
Add the following command to your
.zshrc
file.For
.rpm
or.deb
package installsecho 'fpath=( /usr/share/sdb/zsh "${fpath[@]}" )' >> ~/.zshrc
For tarball installs
echo 'fpath=( <path-to-toolbox>/sdb-autocomplete "${fpath[@]}" )' >> ~/.zshrc
where
<path-to-toolbox>
is the full path to the folder that contains the Toolbox binaries (the folder that is created when the.tar.gz
file is extracted). -
Add the following command to your
.zshrc
file.echo "autoload -U compinit; compinit" >> ~/.zshrc
-
This feature is now enabled for each new terminal session. For those terminal sessions that are already open, source your shell profile to use this feature.
source ~/.zshrc
Using Toolbox Auto-Completion
When entering a Toolbox command such as sdb-admin
, sdb-deploy
, sdb-report
, and sdb-toolbox-config
, press the [Tab] key to see a list of available sub-commands and flags.
sdb-deploy [Tab]
For tarball installs, run this command from the folder that is created when the Toolbox .tar.gz
file is extracted.
./sdb-deploy [Tab]
This will display the list of available sub-commands (with a description of the command if using zsh
):
cluster-in-a-box destroy-cluster env
generate-cluster-file install list-versions
setup-cluster ui uninstall
upgrade version
Note: In zsh
, you may select a sub-command by pressing the [Tab] key repeatedly.
Example
To complete sdb-deploy install --file-path
, begin typing the command and press the [Tab] key.
sdb-deploy i[Tab]
This will auto-complete to the install
sub-command:
sdb-deploy install
You may then use the same method to find available flags and auto-complete the rest of the command.
Where:
sdb-deploy install --fi[Tab]
becomes:
sdb-deploy install --file-path
Resources
Refer to the SingleStore Tools Reference for more information on the available sub-commands and flags for each Toolbox command.