-
Notifications
You must be signed in to change notification settings - Fork 129
Preview
You can make full use of fzf's --preview option when using fzf-tab .
If you don't know what it is, please read junegunn/fzf#preview-window first.
An example:
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'exa -1 --color=always $realpath' # remember to use single quote here!!!
fzf-tab defines some variables for better previewing.
This is the string fzf shows to you.
Example: --accessed use the accessed timestamp field, README.md
This is the real string to be insert into your commandline.
For example, if the $desc is --accessed use the accessed timestamp field, the $word is --accessed.
This is the description of the group which the $word belongs to.
For example, --accessed belongs to group named [option], and README.md belongs to [filename].
README.md belongs to [filename] to completing exa, but belongs to [files] when completing ls.
NOTE: To use this variable, please make sure you have set zstyle ':completion:*:descriptions' format '[%d]'.
If you are completing a path and want to access this path when previewing, then you should use $realpath.
For example, if you are completing directories in /usr/, $word will be something like bin, lib,
but $realpath will be /usr/bin, /usr/lib.
Feel free to contribute your preview~

# give a preview of commandline arguments when completing `kill`
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
zstyle ':fzf-tab:complete:(kill|ps):argument-rest' fzf-preview \
[[ $group == "[process ID]" ]] && ps --pid=$word -o cmd --no-headers -w -w'
zstyle ':fzf-tab:complete:(kill|ps):argument-rest' fzf-flags --preview-window=down:3:wrap