-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Configuring shell key bindings
Junegunn Choi edited this page Oct 8, 2016
·
12 revisions
You can preview the content of the file under the cursor by setting --preview
option.
# 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'"
Sorting is disabled by default to respect chronological ordering. You can dynamically enable sorting by pressing CTRL-R
again, but if you like it to be enabled by default you can add --sort
to FZF_CTRL_R_OPTS
. Also, if you prefer to use exact (non-fuzzy) matching, add --exact
.
export FZF_CTRL_R_OPTS='--sort --exact'
Commands that are too long are not fully visible on screen. We can use --preview
option to display the full command on the preview window. In the following example, we bind ?
key for toggling preview window.
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden --bind '?:toggle-preview'"
fzf-history-widget-accept() {
fzf-history-widget
zle accept-line
}
zle -N fzf-history-widget-accept
bindkey '^X^R' fzf-history-widget-accept
bind "$(bind -s | grep '^"\\C-r"' | sed 's/"/"\\C-x/' | sed 's/"$/\\C-m"/')"
There is an open issue for this; #477. We have a solution for zsh, but not for bash.
Use tree
command to show the content of the directory on the preview window.
export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200'"