[Documentation] preview cmd variables must be exported to be read by _fzf_preview_file
Susensio opened this issue · comments
This took me a while to debug.
When setting fzf_preview_file_cmd
and fzf_preview_dir_cmd
as stated in https://github.com/PatrickF1/fzf.fish#change-how-search-directory-previews-directories-and-regular-files example:
set fzf_preview_dir_cmd eza --all --color=always
set fzf_preview_file_cmd cat -n
those settings are not honored. This is because (I think) _fzf_preview_file
is executed in a subshell by fzf
.
I've tried to export those variables:
set -x fzf_preview_dir_cmd eza --all --color=always
set -x fzf_preview_file_cmd cat -n
with no luck
Sorry, I was guarding some part of my config with if not status is-interactive
and that was the problem.
Hi, did you see https://github.com/PatrickF1/fzf.fish/wiki/Troubleshooting#fzf_preview_file_cmd-and-fzf_preview_dir_cmd-not-being-used? How can I reword that so it's easier for people to find?
Well, I think you did well, I just didn't thought of checking the wiki..
I have a conf.d/fzf.fish
file that configures this plugin, and some parts need to be guarded in case I'm bootstraping fisher
# Better dir and file previews
set fzf_preview_dir_cmd preview
set fzf_preview_file_cmd preview
# Edit with nvim on search-directory
set fzf_directory_opts --bind "ctrl-e:execute($EDITOR {} &> /dev/tty)"
# Exclude the command timestamp from the search scope when in Search History
set fzf_history_opts "--nth=4.."
# Make history respect chronological order
set fzf_history_opts --no-sort
# Not neccesary if not interactive, besides this guards on bootstrap
if not status is-interactive
exit
end
# Default bindings but bind Search Directory to Ctrl+F and Search Variables to Ctrl+Alt+V prepending $
fzf_configure_bindings --directory=\cf --variables=
This needs to be guarded because fzf_configure_bindings
does not exist on boostrap until I do a fisher update
For reference, how I bootstrap fisher:
# Do not pollute fish config folder, use a subfolder
# https://github.com/jorgebucaran/fisher/issues/677
if set -q XDG_CONFIG_HOME
set -gx fisher_path $XDG_CONFIG_HOME/fish/fisher
else
set -gx fisher_path $HOME/.config/fish/fisher
end
set fish_function_path $fish_function_path[1] $fisher_path/functions $fish_function_path[2..-1]
set fish_complete_path $fish_complete_path[1] $fisher_path/completions $fish_complete_path[2..-1]
# Automatic things only in interactive mode
if status is-interactive
if not functions -q fisher
echo "Fisher not found, installing..."
curl -sL https://git.io/fisher | source && fisher update || fisher install "jorgebucaran/fisher"
end
end
for file in $fisher_path/conf.d/*.fish
source $file
end