Completion Commands#
To simplify the user experience while using Simplicity Commander's command line interface (CLI), command completion (TAB completion) scripts can be generated using the completion generate
command. The scripts can be used in your shell environment in order to provide completion for all available commands, sub commands and options. The scripts also provide automatic serial number completion for currently connected JLink devices when providing the --serialno
option (or its short form, -s
), as well as completions for device part numbers to the --device
option (or its short form, -d
).
Completion scripts can be generated for the following Unix-based shells:
bash
zsh
fish
Generating a completion script is fast, and thus running Simplicity Commander at the startup of the shell is a simple way to ensure that the TAB completions are available in the shell session. This will also ensure that with later releases of Simplicity Commander (assuming the previous application package is replaced by the newer version), any new commands, sub commands or options will be added to the TAB completion.
The procedures for employing the completion scripts depend on the shell in use, and on the exact setup of the shell environment. For bash and zsh, the completion script can be installed by sourcing the script in the shell's configuration file (.bashrc
and .zshrc
, respectively). For fish, one common practice is to place completion scripts within the completions
directory inside fish's configuration folder, which on most systems will be ~/.config/fish/completions
.
Generate Completion Script#
Simplicity Commander supports generating completion scripts using the completion generate
command. You can provide an alternative alias for which the completions will trigger, using the --alias
option. This is useful if you have an alias for your installation of Simplicity Commander already defined in your shell environment. Aliases must contain alphanumeric characters only (underscores are also allowed), and cannot start with a number. The default alias is 'commander'.
By default, this command will output the completion script directly to the console. If you instead want to save the output script to a file, you can provide the --outfile
option.
Command Line Syntax
$ commander completion generate <shell> [--alias <alias> --outfile <output file>]
Command Line Input Example
$ commander completion generate bash --alias cmder --outfile cmder-completion.sh
This command line generates a TAB completion script for bash, which will trigger for the 'cmder' keyword, and saves it to the file 'cmder-completion.sh'.
Command Line Output Example
Completion script saved at 'path/to/cmder-completion.sh'
DONE
Install Completion Script#
Here follows basic examples on how to install the scripts on bash, zsh and fish shells. All these approaches require that the Simplicity Commander executable is in your system's PATH or is otherwise visible to your shell environment.
Using this approach, whenever newer versions of Simplicity Commander are released, simply replace the existing Commander application package with the new version. All completions will be kept up-to-date, making this installation a one-time only procedure.
bash
Add the following line to your .bashrc
configuration file:
source <(commander completion generate bash)
zsh
Add the following line to your .zshrc
configuration file:
source <(commander completion generate zsh)
fish
Add the following line to your ~/.config/fish/config.fish
configuration file:
commander completion generate fish > ~/.config/fish/completions/commander.fish