You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Supercharge your Salesforce CLI game with FZF! (For Bash and Zsh)
2
2
3
3
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!
4
4
@@ -9,29 +9,47 @@ See it in action below
9
9
#### Pre-Requisites
10
10
11
11
-[FZF](https://github.com/junegunn/fzf)
12
-
(If you use the command line in any capacity, do yourself and favor and install fzf. Seriously, even if you don't plan
12
+
(If you use the cli more than the average user, do yourself and favor and install fzf. Seriously, even if you don't plan
13
13
on using this sfdx script, install FZF. It will change your life.)
14
14
-[jq](https://stedolan.github.io/jq/download/)
15
15
-[Salesforce CLI](https://developer.salesforce.com/tools/sfdxcli) (the npm version installed using `npm i -g sfdx-cli`)
16
-
- Bash shell
16
+
- Bash or Zsh shell
17
17
18
18
#### Setup
19
19
20
-
- Copy [fzf-keybindings.bash](https://github.com/junegunn/fzf/blob/master/shell/key-bindings.bash) from the `fzf` repo
21
-
if you haven't already as part of installation, to a suitable directory and add it to your `~/.bashrc` file.
22
-
- Add the contents of the [fzf-keybindings.bash](./fzf-key-bindings.bash) file from this repo to the appropriate sections in your `fzf-keybindings.bash` file above. (The functions `__fzf_sfdx` and `__fzf_sfdx_flags__` go in the functions section and the
23
-
keybindings go in the keybindings section). Note that the keybinding I'm using here is `Ctrl-l`. Feel free to change it in this file.
24
-
- Run the following command `sfdx commands --json > ~/.sfdxcommands.json`. (You can add it your `.bashrc` or `.profile`
25
-
file to run it automatically every time you login. Note that this could add a noticeable delay to launching a new terminal)
20
+
##### Bash
21
+
22
+
- Copy [fzf-key-bindings.bash](./fzf-key-bindings.bash) to a directory on your machine.
23
+
- Replace the path to the `key-bindings.bash` file in `$HOME/.fzf.bash` with the path to the file above.
24
+
- Run the following command `sfdx commands --json > ~/.sfdxcommands.json`. (You can add it your `.bashrc`
25
+
file to run it automatically every time you login. Note that this could add a noticeable delay to launching a new terminal).
26
+
- Restart your shell or run `source $HOME/.bashrc`.
27
+
28
+
##### Zsh
29
+
30
+
- Copy [fzf-key-bindings.zsh](./fzf-key-bindings.zsh) to a directory on your machine.
31
+
- Replace the path to the `key-bindings.zsh` file in `$HOME/.fzf.zsh` with the path to the file above.
32
+
- Run the following command `sfdx commands --json > ~/.sfdxcommands.json`. (You can add it your `.zshrc`
33
+
file to run it automatically every time you login. Note that this could add a noticeable delay to launching a new terminal).
34
+
- Restart your shell or run `source $HOME/.zshrc`.
26
35
27
36
#### Usage
28
37
29
38
- Type `Ctrl-e` on a new line to bring up the list of commands to fuzzy search through. The preview window shows up to
30
39
the right with the command description and examples. Use arrow keys or `Ctrl-k` and `Ctrl-J` to move up and down through the list of commands. Use `Alt-K` and `Alt-J` to move the preview window up and down, which can be useful for commands with long previews. Hit `Enter` to select a command and print it out onto the terminal.
31
-
- Once a command is selected, or if you have typed an `sfdx` command in manually (without fzf), hitting `Ctrl-l` again will bring
40
+
- Once a command is selected, or if you have typed an `sfdx` command in manually (without fzf), hitting `Ctrl-e` again will bring
32
41
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. Hit `Enter` to select the flag and print it out onto the terminal.
33
42
34
43
#### Notes
35
44
36
45
- This script only works when `sfdx` is 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)
37
46
- If you don't end up adding `sfdx commands --json > ~/.sfdxcommands.json` to your `.profile` or `.bashrc` file, run the command manually from time to time to keep up with updates to the CLI
47
+
- The script binds `Ctrl-e` to bring up sfdx commands. If you'd like to change the mapping, you can change it [here](./fzf-key-bindings.bash#L130) (for bash) or [here](./fzf-key-bindings.zsh#L151) (for zsh)
48
+
- If you'd like to use this in VS Code's integrated terminal, you'd need to prevent `Ctrl-e` from 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 to `settings.json`. Note the hyphen(`-`) before the setting name to unbind the action.
0 commit comments