Shell Completion

If you're using JFrog CLI from a bash, zsh, or fish shell, you can install JFrog CLI's auto-completion scripts to improve your command-line experience. Auto-completion helps save time and reduces errors by suggesting potential command options and arguments as you type.

Auto-completion allows you to:

  • Increase command-line efficiency by reducing typing
  • Minimize typographical errors in commands and options
  • Discover available commands and options through in-line suggestions

What is JFrog CLI?: JFrog CLI is a command-line interface for interacting with JFrog Artifactory and other JFrog products. It simplifies various functions, such as uploading or downloading files, managing repositories, and more. For more information, refer to the JFrog CLI.


How to Enable Auto-Completion

The method of enabling auto-completion varies based on the shell you are using (bash, zsh, or fish).

Install JFrog CLI with Homebrew

If you're installing JFrog CLI using Homebrew, the bash, zsh, or fish auto-complete scripts are automatically installed. However, you need to ensure that your .bash_profile or .zshrc files are correctly configured. Refer to the Homebrew Shell Completion documentation for specific instructions.

Using Oh My Zsh?

If you are using the Oh My Zsh framework, follow these steps to enable JFrog CLI auto-completion:

  1. Open your zsh configuration file, located at $HOME/.zshrc, with any text editor.
your-text-editor $HOME/.zshrc
  1. Locate the line starting with plugins=.

  2. Add jfrog to the list of plugins. For example:

plugins=(git mvn npm sdk jfrog)
  1. Save and close the file.

  2. Finally, apply the changes by running:

source $HOME/.zshrc

Other Installation Methods

If you're not using Homebrew or Oh My Zsh, you can manually install the auto-completion scripts for your specific shell:

For Bash

To install auto-completion for bash, run the following command:

jf completion bash --install

This generates a completion script at ~/.jfrog/jfrog_bash_completion and displays the following output:

Generated bash completion script at /Users/<username>/.jfrog/jfrog_bash_completion.
To activate auto-completion on this shell only, source the completion script by running the following command:

source /Users/<username>/.jfrog/jfrog_bash_completion

To activate auto-completion permanently, put the above command in ~/.bashrc or ~/.bash_profile, depending on your operating system.

To activate permanently, add the following line to your ~/.bashrc or ~/.bash_profile:

source ~/.jfrog/jfrog_bash_completion

Then restart your terminal or run source ~/.bashrc.

For Zsh

To install auto-completion for zsh, run the following command:

jf completion zsh --install

This generates a completion script at ~/.jfrog/jfrog_zsh_completion and displays the following output:

Generated zsh completion script at /Users/<username>/.jfrog/jfrog_zsh_completion.
To activate auto-completion on this shell only, source the completion script by running the following three commands:

autoload -Uz compinit
compinit
source /Users/<username>/.jfrog/jfrog_zsh_completion

To activate auto-completion permanently, put the above three commands in ~/.zshrc.

Important: Zsh requires three commands to activate completion. To activate permanently, add the following lines to your ~/.zshrc:

autoload -Uz compinit
compinit
source ~/.jfrog/jfrog_zsh_completion

Then restart your terminal or run source ~/.zshrc.

For Fish

To install auto-completion for fish, run the following command:

jf completion fish --install

This generates a completion script at ~/.config/fish/completions/jf.fish and displays the following output:

Generated fish completion script at /Users/<username>/.config/fish/completions/jf.fish

No additional configuration is required. Fish automatically loads completion scripts from the ~/.config/fish/completions/ directory. Simply restart your fish shell or open a new terminal session.


Verifying Installation

After installing the completion scripts, you can verify that auto-completion works by typing jf followed by pressing the Tab key. You should see a list of available commands and options.

Example:

$ jf <TAB>
access-token-create  completion           config               how                  login
mc                   options              pl                   plugin               rt

Note: The exact list of commands may vary depending on your JFrog CLI version, installed plugins, and enabled features.


Generate Scripts without Installation

If you prefer to output the completion script to stdout without installing it, omit the --install flag:

# Output bash completion script to stdout
jf completion bash

# Output zsh completion script to stdout
jf completion zsh

# Output fish completion script to stdout
jf completion fish

You can redirect the output to a custom location:

jf completion bash > /custom/path/jfrog_completion

Command Reference

CommandSynopsisKey Option
jf completion bashjf completion bash [options]--install — Install the script instead of printing to stdout
jf completion zshjf completion zsh [options]--install — Install the script instead of printing to stdout
jf completion fishjf completion fish [options]--install — Install the script instead of printing to stdout

All three commands accept one option:

FlagDefaultDescription
--installfalseSet to true to install the completion script instead of printing to standard output

For detailed usage of each shell's completion command, refer to the how-to sections above.


What’s Next

For further customization, review all available environment variables.