Fuzzy find Salesforce CLI commands and flags as you type, with live previews of what each command and flag does. No more typos, switching to the browser or running help to lookup commands and associated options. Autocomplete doesn't get any better than this!
See it in action below
- FZF (If you use the cli more than the average user, do yourself and favor and install fzf. Seriously, even if you don't plan on using this sfdx script, install FZF. It will change your life.)
- jq
- Salesforce CLI (the npm version installed using
npm i -g sfdx-cli) - Bash or Zsh shell
- Copy fzf-key-bindings.bash to a directory on your machine.
- Replace the path to the
key-bindings.bashfile in$HOME/.fzf.bashwith the path to the file above. - Run the following command
sfdx commands --json > ~/.sfdxcommands.json. (You can add it your.bashrcfile to run it automatically every time you login. Note that this could add a noticeable delay to launching a new terminal). - Restart your shell or run
source $HOME/.bashrc.
- Copy fzf-key-bindings.zsh to a directory on your machine.
- Replace the path to the
key-bindings.zshfile in$HOME/.fzf.zshwith the path to the file above. - Run the following command
sfdx commands --json > ~/.sfdxcommands.json. (You can add it your.zshrcfile to run it automatically every time you login. Note that this could add a noticeable delay to launching a new terminal). - Restart your shell or run
source $HOME/.zshrc.
- Type
Ctrl-eon a new line to bring up the list of commands to fuzzy search through. The preview window shows up to the right with the command description and examples. Use arrow keys orCtrl-kandCtrl-Jto move up and down through the list of commands. UseAlt-KandAlt-Jto move the preview window up and down, which can be useful for commands with long previews. HitEnterto select a command and print it out onto the terminal. - Once a command is selected, or if you have typed an
sfdxcommand in manually (without fzf), hittingCtrl-eagain will bring up the list of flags associated with the command. As you scroll through the list of flags, the preview window will show a description of the flag and some of its properties. HitEnterto select the flag and print it out onto the terminal.
- This script only works when
sfdxis the only command on a line (i.e. doesn't work if you are trying to pipe the output of another command to sfdx, for example) - If you don't end up adding
sfdx commands --json > ~/.sfdxcommands.jsonto your.profileor.bashrcfile, run the command manually from time to time to keep up with updates to the CLI - The script binds
Ctrl-eto bring up sfdx commands. If you'd like to change the mapping, you can change it here (for bash) or here (for zsh) - If you'd like to use this in VS Code's integrated terminal, you'd need to prevent
Ctrl-efrom being hijacked by VSC to quick open files and have it be sent to the shell itself. This can be accomplished by adding the following line tosettings.json. Note the hyphen(-) before the setting name to unbind the action.
"terminal.integrated.commandsToSkipShell": [
"-workbench.action.quickOpen"
]