From b8579d9cdf80fe3d9c7a759e994acb5fbb4a0654 Mon Sep 17 00:00:00 2001 From: Patrick Fong Date: Thu, 15 Apr 2021 17:02:07 -0700 Subject: [PATCH] fixed --- functions/__fzf_preview_file.fish | 6 +++++- functions/__fzf_search_current_dir.fish | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/functions/__fzf_preview_file.fish b/functions/__fzf_preview_file.fish index ac1be57e..d6c05e2a 100644 --- a/functions/__fzf_preview_file.fish +++ b/functions/__fzf_preview_file.fish @@ -1,5 +1,9 @@ # helper function for __fzf_search_current_dir -function __fzf_preview_file --argument-names file_path --description "Print a preview for the given file based on its file type." +function __fzf_preview_file --description "Print a preview for the given file based on its file type." + # because there appears to guarantee that __fzf_search_current_dir passes the path to __fzf_preview_file + # as one argument, we collect all the arguments into one single variable + set file_path $argv + if test -f "$file_path" # regular file bat --style=numbers --color=always "$file_path" else if test -d "$file_path" # directory diff --git a/functions/__fzf_search_current_dir.fish b/functions/__fzf_search_current_dir.fish index 033fcaf8..50c05f3e 100644 --- a/functions/__fzf_search_current_dir.fish +++ b/functions/__fzf_search_current_dir.fish @@ -16,7 +16,7 @@ function __fzf_search_current_dir --description "Search the current directory. R if string match --quiet -- "*/" $token && test -d "$unescaped_exp_token" set --append fd_opts --base-directory=$unescaped_exp_token # use the directory name as fzf's prompt to indicate the search is limited to that directory - set --prepend fzf_arguments --prompt="$unescaped_exp_token" --preview="__fzf_preview_file $expanded_token'{}'" + set --prepend fzf_arguments --prompt="$unescaped_exp_token" --preview="__fzf_preview_file $expanded_token{}" set file_paths_selected $unescaped_exp_token(fd $fd_opts 2>/dev/null | fzf $fzf_arguments) else set --prepend fzf_arguments --query="$unescaped_exp_token" --preview='__fzf_preview_file {}'