m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-17 15:53:39 -05:00

Created Configuring shell key bindings (markdown)

Junegunn Choi
2016-10-09 04:13:38 +09:00
parent 71ef8907a8
commit f22d158f02

@@ -0,0 +1,61 @@
## `CTRL-T`
### Preview
You can preview the content of the file under the cursor by setting `--preview` option.
```sh
# Using highlight (http://www.andre-simon.de/doku/highlight/en/highlight.html)
export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null | head -200'"
```
## `CTRL-R`
### Sorting and exact matching
Sort is disabled by default to respect chronological ordering. You dynamically toggle sorting by pressing `CTRL-R` again, but if you like to enable sorting by default you can add `--sort` to `FZF_CTRL_R_OPTS`. Also, if you prefer to use exact matching, add `--exact`.
```sh
export FZF_CTRL_R_OPTS='--sort --exact'
```
### Preview
Commands that are too long are not fully visible on screen. You can use `--preview` option to see the full command on the preview window. In the following example, we bind `?` key to toggle preview window.
```sh
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden --bind '?:toggle-preview'"
```
### Directly executing the command (CTRL-X CTRL-R)
#### zsh
```sh
fzf-history-widget-accept() {
fzf-history-widget
zle accept-line
}
zle -N fzf-history-widget-accept
bindkey '^X^R' fzf-history-widget-accept
```
#### bash
```sh
bind "$(bind -s | grep '^"\\C-r"' | sed 's/"/"\\C-x/' | sed 's/"$/\\C-m"/')"
```
### Dynamically choose to execute or edit
There is an open issue for this; [#477](https://github.com/junegunn/fzf/issues/477). We have a solution for zsh, but not for bash.
## `ALT-C`
### Preview
Use `tree` command to show the content of the directory on the preview window.
```sh
export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200'"
```