Autocomplete Salesforce CLI Commands and Flags
You must set up the autocomplete feature before you can use it. Autocomplete supports these shells:
- Bash: macOS and Linux
- Z shell (zsh): macOS and Linux
- PowerShell: Typically used on Microsoft Windows, although you can also install PowerShell on macOS and Linux.
Configure Autocomplete
- Open a terminal window (macOS and Linux) or Powershell command window (Windows).
-
Run this command, which builds the autocomplete cache on your computer:
sf autocomplete
- Follow the displayed instructions, which reflect the shell you’re currently using.
After you update Salesforce CLI to a new version, run sf autocomplete --refresh-cache to ensure that autocomplete works correctly on any new commands.
Use Autocomplete
Let’s look at some examples using Z shell (zsh). In a terminal or command window, type sf, a space, and then <TAB> until you see the full list of top-level topics and commands with their summaries.

Let’s say you want to deploy metadata from your Salesforce DX project; the project topic looks promising! To see the list of sub-topics under project, type the letters pr and then <TAB>.

The output includes a deploy sub-topic; we’re getting there! To drill down, type the letters dep and <TAB>, and the commands in the deploy sub-topic are displayed. Keep typing and tabbing this way until you get to the full command to deploy metadata, which is project deploy start.
Now that you found the correct command, you probably now want to see the available flags. Simply type - (hyphen) and <TAB> to see the full list of flags, with their short and long names and summaries:

Type the first letter of a flag, then <TAB> until you’ve autocompleted the flag name.
You can also use autocomplete to specify a value for some flags. For example, if your current directory is a Salesforce DX project and you want to specify a manifest file for the --manifest flag, press <TAB> after the flag to see a list of files. Then enter the first letter and <TAB> until you complete the name of the file, such as package.xml.
