Enable Shell Auto-Completion for JFrog CLI
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
This topic covers the following tasks:
- Install JFrog CLI with Homebrew
- Enable auto-completion with Oh My Zsh
- Install manually for Bash, Zsh, or Fish
- Verify installation
- Generate scripts without installation
Prerequisites
Before enabling auto-completion, ensure the following:
- JFrog CLI is installed — run
jf --versionto confirm. If not installed, see Download and Install the JFrog CLI. - Your shell is identified — this page covers bash, zsh, and fish. Check your current shell with
echo $SHELL. - Oh My Zsh path only: Oh My Zsh must already be installed. If you are not using Oh My Zsh, skip to Other Installation Methods.
- Fish path only: The fish shell must be installed and set as your shell to use fish completions.
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.
Homebrew installs completion scripts to the following locations:
- zsh:
$(brew --prefix)/share/zsh/site-functions/(for example,/opt/homebrew/share/zsh/site-functions/on Apple Silicon) - bash:
$(brew --prefix)/etc/bash_completion.d/ - fish:
$(brew --prefix)/share/fish/vendor_completions.d/
To verify that the JFrog CLI completion script was installed, run:
ls $(brew --prefix)/share/zsh/site-functions/ | grep jfIf no output is returned, refer to the Homebrew Shell Completion documentation to configure your shell profile, or use the manual installation method instead.
Using Oh My Zsh?
Prerequisite
: Oh My Zsh must already be installed. If you are not using Oh My Zsh, skip to Other Installation Methods.
To enable JFrog CLI auto-completion with Oh My Zsh:
- Open your zsh configuration file, located at
$HOME/.zshrc, with any text editor. For example:
nano $HOME/.zshrc-
Locate the line starting with
plugins=. -
Add
jfrogto the list of plugins. For example:
plugins=(git mvn npm sdk jfrog)-
Save and close the file.
-
Finally, apply the changes by running:
source $HOME/.zshrcOther 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 --installThis 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_completionThen restart your terminal or run source ~/.bashrc.
For Zsh
To install auto-completion for Zsh:
- Run the following command:
jf completion zsh --installThis 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_completionThen restart your terminal or run source ~/.zshrc.
Note
: If your
~/.zshrcalready callscompinit(common when using a zsh framework or plugin manager), you only need to add thesourceline. Adding a secondcompinitcall is harmless but unnecessary.
For Fish
Prerequisite
: The fish shell must be installed and set as your shell to use fish completions. To check, run
which fish. If fish is not installed, visit fishshell.com for installation instructions.
To install auto-completion for Fish:
- Run the following command:
jf completion fish --installThis 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.
Note
: The fish completion script is significantly larger than the bash or zsh equivalents (approximately 300 KB) because it pre-computes completions for all commands and flags. This is expected behavior and does not affect performance during normal use.
Re-running the install command
: If you run
jf completion <shell> --installagain, the existing completion script is silently overwritten with a fresh copy. This is safe to do after upgrading JFrog CLI.
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 top-level commands and subcommands.
If auto-completion is working correctly, pressing Tab after jf will display commands such as config, rt, completion, login, and many others depending on your CLI version, installed plugins, and enabled features. The list will be substantially longer than a few entries — JFrog CLI exposes commands for Artifactory, Xray, Distribution, Lifecycle, package managers, and more.
Tip
: If no suggestions appear after pressing Tab, ensure you have sourced the completion script in your current shell session, or opened a new terminal after adding the
sourceline to your shell profile.
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 fishYou can redirect the output to a custom location:
jf completion bash > /custom/path/jfrog_completionCommand Reference
| Command | Synopsis | Key Option |
|---|---|---|
jf completion bash | jf completion bash [options] | --install — Install the script instead of printing to stdout |
jf completion zsh | jf completion zsh [options] | --install — Install the script instead of printing to stdout |
jf completion fish | jf completion fish [options] | --install — Install the script instead of printing to stdout |
All three commands accept one option:
| Flag | Default | Description |
|---|---|---|
--install | false | When present, installs the completion script to the default path instead of printing to standard output |
For detailed usage of each shell's completion command, refer to the how-to sections above.
Updated 12 days ago
