fzf.vim icon indicating copy to clipboard operation
fzf.vim copied to clipboard

No preview window on Windows

Open SuperCuber opened this issue 3 years ago • 9 comments

  • [x] I have fzf 0.23.0 or above
  • [x] I have read through https://github.com/junegunn/fzf.vim/blob/master/README.md
  • [x] I have read through https://github.com/junegunn/fzf/blob/master/README-VIM.md
  • [x] I have read through the manual page of fzf (man fzf)
  • [x] I have searched through the existing issues

With :Ag, there's a preview window but with :Rg there isn't. I'd expect these commands to basically produce exactly the same visual output, but this is not the case. Also I'm not quite sure how to enable the preview window, g:fzf_preview_window and <C-/> seem to have no effect in the Rg window.

Environment: Ubuntu for Ag, Windows for Rg

SuperCuber avatar Feb 08 '21 15:02 SuperCuber

Seems like this is an environment issue. I haven't noticed that in :messages there's Preview window not supported (bash not found in PATH) since it's immediately covered up by the --TERMINAL-- text.

Is there a reason bash is required for preview?

SuperCuber avatar Feb 11 '21 15:02 SuperCuber

My guess is that's because currently only this shell script is supported for creating the preview: https://github.com/junegunn/fzf.vim/blob/master/bin/preview.sh Also there are some assumptions made about what shell you are using on which OS (which should not be coupled to begin with), see here: https://github.com/junegunn/fzf.vim/issues/1139 This would require some more logic to check the actual shell instead of the OS and also offer preview scripts for bash, CMD and powershell/pwsh at a minimum, I guess.

kmoschcau avatar Mar 18 '21 13:03 kmoschcau

Does it work with pwsh now?

hungpham3112 avatar Feb 24 '22 01:02 hungpham3112

I also recently found another dimension to this. Recent Windows versions seem to add bash to the Windows PATH when WSL2 is installed, which starts a bash session in a WSL2 instance. For some reason, even though Vim's 'shell' is set to "cmd", fzf seems to pick bash as the shell to run the preview command. This then leads to bash being told to execute something on a Windows path with the backslashes removed (I guess because they are seen as escapes), a drive letter in it and path section abbreviations (the Progra~1 stuff). So you can have fzf and fzf.vim properly installed on both Windows and the WSL2 instance and it will still not work.

kmoschcau avatar Feb 24 '22 06:02 kmoschcau

Hi, The error preview window not support (bash not found in PATH) indicates that vim cannot find the path to the Bash shell on your system. It solves this Error. We must add bash in the PATH.

  1. Win + x --->System --->advanced system settings ---> environment variables. in user variables, select path and clic edit.
  2. If you have installed GIT, the path is C:\Program Files\Git\bin . add it in the step 1.
  3. Try typing in cmd bash

Crzek avatar Jan 14 '23 17:01 Crzek

@Crzek We recently updated the code to automatically pick up C:\Program Files\Git\bin\bash.exe ( bdf48c282ad2174c25c059b3cdb7956427b07a99). Please update and test if it works as expected.

junegunn avatar Jan 16 '23 04:01 junegunn

@junegunn, you may also need to check if it is in C:\Users\USERNAME\scoop\apps\git\current\bin\bash.exe.

scoop install git will install Git for Windows to C:\Users\USERNAME\scoop\apps\git\current.

The USERPROFILE environment variable should give the C:\Users\USERNAME part.

ykhan21 avatar Feb 03 '24 21:02 ykhan21

@ykhan21 Thanks. Can you open a pull request?

junegunn avatar Feb 04 '24 00:02 junegunn

If someone else can add it, that would be great. I'm having the same issues with fzf.vim as https://github.com/junegunn/fzf.vim/issues/703, so I can't test any changes I make.

In the Git Bash shell that comes with Git for Windows, most of the fzf commands do not work. Running them opens an empty cmd shell.

ykhan21 avatar Feb 05 '24 02:02 ykhan21