Skip to content

Instantly share code, notes, and snippets.

@ddrscott
Created May 16, 2017 18:38
Show Gist options
  • Save ddrscott/8db948aeb6a7922566bca828f612c258 to your computer and use it in GitHub Desktop.
Save ddrscott/8db948aeb6a7922566bca828f612c258 to your computer and use it in GitHub Desktop.
FZF with highlighted source preview
# FZF Stuff
export FZF_DEFAULT_COMMAND='ag -g ""'
# `highlight` preview options
# WARNING: depends on `brew install highlight`
export FZF_HIGHLIGHT_PREVIEW_OPTS="--height 100% --preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null' --preview-window=up:40%"
# When pressing CTRL-T, only search file names (not directories)
# and display highlighted source in preview window
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_CTRL_T_OPTS="--delimiter '/' --nth=-1 $FZF_HIGHLIGHT_PREVIEW_OPTS"
@ddrscott
Copy link
Author

ddrscott commented May 16, 2017

CTRL-T Demo

fzf-ctrl-t-demo2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment