kelleyma49 / PSFzf

A PowerShell wrapper around the fuzzy finder fzf
MIT License
795 stars 36 forks source link

Text preview with bat is not available after PSFzf version 2.1.0 #65

Closed ssxwcz closed 3 years ago

ssxwcz commented 3 years ago

After upgrading PSFzf to version 2.1.0, I found that I could not use bat for text preview. This is my fzf configuration.

$env:FZF_DEFAULT_OPTS="--prompt '⯈ ' --height 50% --layout=reverse --border 
--color=dark
--color=fg:-1,bg:-1,hl:#5fff87,fg+:-1,bg+:-1,hl+:#ffaf5f
--color=info:#af87ff,prompt:#5fff87,pointer:#ff87d7,marker:#ff87d7,spinner:#ff87d7"
$env:FD_OPTIONS="--hidden --follow"
$env:FZF_DEFAULT_COMMAND="fd --type f --type l {0}" -f $env:FD_OPTION
$env:FZF_CTRL_T_OPTS='--preview "bat --style=numbers,changes,header --color=always --theme=Dracula --line-range :500 {}  || cat {}"'

When in the user directory, it can preview normally. 1

When entering a random directory, I can't use bat to preview, and the system can't find the specified file. 2

kelleyma49 commented 3 years ago

try https://www.powershellgallery.com/packages/PSFzf/2.2.0

ssxwcz commented 3 years ago

try https://www.powershellgallery.com/packages/PSFzf/2.2.0

Still the same problem, prompting the system can not find the specified path image

rashil2000 commented 3 years ago

Hi @kelleyma49, still facing the same issue with bat preview in locations other than home directory. My PsFzf version is 2.2.6.

These are the variables I've set:

FZF_CTRL_T_COMMAND             rg --files -S -. -L -g "!{.git}"
FZF_CTRL_T_OPTS                --preview "bat --color=always --line-range=:500 {}"
FZF_DEFAULT_OPTS               --exact --no-sort --reverse --cycle
rashil2000 commented 3 years ago

I think the issue is that the preview only seems to work if the full path is shown in the fzf list. This is unique to PsFzf. In bash, relative paths work fine with preview.

rashil2000 commented 3 years ago

The issue was with working directory not getting set correctly. I have made a fix #86