Replies: 1 comment
-
Just a follow up on my question, this was already discussed in #256. My current solution: # no prview for options
zstyle ':fzf-tab:complete:*:options' fzf-preview ''
# preview for files
zstyle ":fzf-tab:complete:*:argument-rest" fzf-preview '
if [[ -d "$realpath" ]]; then
tree -C -L 3 "$realpath"
elif [[ -f "$realpath" ]]; then
if $(grep -qI . "$realpath"); then
bat -p --color=always "$realpath"
else
echo "Realpath: $realpath"
# Use gstat for Linux; fallback to stat for macOS or BSD
local stat_cmd
local -a stat_opts
local arch=$(uname -s)
if [[ $OSTYPE = darwin* ]]; then
# Darwin / FreeBSD version
local gprefix
command -v gstat &>/dev/null && gprefix=g
echo "Yes"
if [[ -z $gprefix ]]; then
stat_cmd="stat"
stat_opts=(
"-f"
"File: %N\nLocation: %d:%i\nMode: %Sp (%Mp%Lp)\nLinks: %l\nOwner: %Su/%Sg\nSize: %z (%b blocks)\nChanged: %Sc\nModified: %Sm\nAccessed: %Sa"
)
fi
else
# Linux or Darwin with GNU support
stat_cmd="${gprefix}stat"
stat_opts=(
"-c"
"File: %N\nType: %F\nLocation: %d:%i\nMode: %A (%a)\nLinks: %h\nOwner: %U/%G\nSize: %s (%b blocks)\nChanged: %z\nModified: %y\nAccessed: %x"
)
fi
echo $($stat_cmd "$stat_opts[@]" "$realpath")
fi
fi' The best would be if |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First of all, thank you very much for the amazing plugin.
I am wondering if there is a simple way to show
fzf-preview
only when completing a selection of files or directories. Normally, if you use the standard zsh completion plugin, the following syntax applies:where
<tag>
defines what kind of items the completion applies to, such asfiles
,options
,commands
,indexes
, etc.I would like to display
fzf-preview
only forfiles
. Currently,fzf-preview
is also fired when for example listing the options ofls
command if I dols -<TAB>
, but of course, this is not ideal because there is nothing to preview for options.I also post here my current configuration so that you get a better idea:
Beta Was this translation helpful? Give feedback.
All reactions