Skip to content

[Documentation] preview cmd variables must be exported to be read by _fzf_preview_file #316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Susensio opened this issue Nov 14, 2023 · 3 comments

Comments

@Susensio
Copy link
Contributor

Susensio commented Nov 14, 2023

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

@Susensio
Copy link
Contributor Author

Sorry, I was guarding some part of my config with if not status is-interactive and that was the problem.

@PatrickF1
Copy link
Owner

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?

@Susensio
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants