Skip to content
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

[bug] g:fzf_vim.preview_bash forced to always use backlash in windows #1543

Open
5 tasks done
DanSM-5 opened this issue May 18, 2024 · 0 comments
Open
5 tasks done

[bug] g:fzf_vim.preview_bash forced to always use backlash in windows #1543

DanSM-5 opened this issue May 18, 2024 · 0 comments

Comments

@DanSM-5
Copy link

DanSM-5 commented May 18, 2024

Using GitFiles or other commands that uses the built-in preview.sh script does not work when using (n)vim from git bash interactive shell. You'll see an error in the preview as follows:

/usr/bin/bash: line 1: C:PROGRA~1Gitusrbinbash.exe: command not found

I set g:fzf_vim.preview_bash to C:/Progra~1/Git/bin/bash.exe but the error persisted as if the preview_bash value was being ignored. I found the issue comes from the function s:bash as it does the following:

  let custom_bash = s:conf('preview_bash', '')
  let git_bash = 'C:\Program Files\Git\bin\bash.exe'
  let candidates = filter(s:is_win ? [custom_bash, 'bash', git_bash] : [custom_bash, 'bash'], 'len(v:val)')

  let found = filter(map(copy(candidates), 'exepath(v:val)'), 'len(v:val)')

The exepath(v:val) will expand the path to a windows style path with backlashes. E.g. the following

:echo filter(map(copy(['C:/Progra~1/Git/bin/bash.exe', 'C:/Program Files/Git/bin/bash.exe']), 'exepath(v:val)'), 'len(v:val)')

will return

['C:\Progra~1\Git\bin\bash.exe', 'C:\Program Files\Git\bin\bash.exe']

Which doesn't work when the interactive shell is git bash. If I manually set the value of s:bash with the content of g:fzf_vim.preview_bash as is (forward slash), then the preview script works fine.

Could the behavior of evaluating the path for g:fzf_vim.preview_bash be changed to take the string as is? If not, could it be a separate variable that is taken as is for the bash preview?

Info

fzf --version
0.52.1 (6432f00)
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

1 participant