junegunn / fzf.vim

fzf :heart: vim
MIT License
9.59k stars 583 forks source link

No preview window on Windows #1242

Open SuperCuber opened 3 years ago

SuperCuber commented 3 years ago

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 commented 3 years ago

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?

kmoschcau commented 3 years ago

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.

hungpham3112 commented 2 years ago

Does it work with pwsh now?

kmoschcau commented 2 years ago

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.

Crzek commented 1 year ago

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
junegunn commented 1 year ago

@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.

ykhan21 commented 7 months ago

@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.

junegunn commented 7 months ago

@ykhan21 Thanks. Can you open a pull request?

ykhan21 commented 7 months ago

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.