Shell completion is available on bash, zsh, and fish. It allows you to press TAB to see available options, suggested arguments, flags, and help information. It will also show remote paths, local backups, and ongoing download IDs when appropriate. It is strongly recommended when using a supported shell.

When jotta-cli updates, it might come with new completions, so it is recommended to update the completions with jotta-cli.

Bash

MacOS

On MacOS you need to install homebrew and then use brew to install bash-completion and then add bash completion to your shell. You might also have to upgrade bash as MacOS ships with a fairly old version and this affects bash-completion scripts.

First, install homebrew from https://brew.sh/ You probably already have this if you installed jotta-cli on MacOS.

Second, check your bash version:

echo $BASH_VERSION


If your bash major version is less than 4 you need to upgrade:

brew install bash


Now you need to whitelist the new bash version by adding it to the list of shells found in the file /etc/shells  

After whitelisting the shell ensure you are running the new version by running 

chsh -s /usr/local/bin/bash

More information on upgrading bash is available here: https://itnext.io/upgrading-bash-on-macos-7138bd1066ba?gi=a0e70050c3ff


Third, install bash-completion: 

brew install bash-completion

and remember to follow the instructions about how to add bash-completion to your shell typically something like below:

Add the following line to your ~/.bash_profile:
  [[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"


Fourth, add the following to your ~/.bash_profile:

. <(jotta-cli completion bash)


Linux

Many linux distros come with bash-completion already loaded. If not you can run 

apt-get install bash-completion

or the non-debian equivalent.

Then, add the following to your ~/.bash_profile or ~/.bashrc :

. <(jotta-cli completion bash)

zsh

If shell completion is not already enabled in your environment, you will need to enable it. You can do this by executing the following once:

echo "autoload -U compinit; compinit" >> ~/.zshrc

To load completions for each session, execute once:

jotta-cli completion zsh > "${fpath[1]}/_jotta-cli"

You will need to start a new shell for this setup to take effect.

fish

To load completions for the current session, execute:

jotta-cli completion fish | source


To load completions for each session, execute (once):

jotta-cli completion fish > ~/.config/fish/completions/jotta-cli.fish
Did this answer your question?