From 3348aef05d02828cd8b071ab29476af2029ea3d3 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 10 Sep 2020 23:20:56 -0400 Subject: [PATCH] [fzf#vim#with_preview] Detect WSL bash on Windows only Close https://github.com/junegunn/fzf.vim/issues/1052 --- autoload/fzf/vim.vim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/autoload/fzf/vim.vim b/autoload/fzf/vim.vim index fa1d43d..a66317d 100644 --- a/autoload/fzf/vim.vim +++ b/autoload/fzf/vim.vim @@ -76,8 +76,6 @@ endfunction " [[spec to wrap], [preview window expression], [toggle-preview keys...]] function! fzf#vim#with_preview(...) - let bash_path = exepath('bash') - let is_wsl_bash = bash_path =~? 'Windows[/\\]system32[/\\]bash.exe$' " Default spec let spec = {} let window = '' @@ -90,7 +88,7 @@ function! fzf#vim#with_preview(...) call remove(args, 0) endif - if empty(bash_path) + if !executable('bash') if !s:warned call s:warn('Preview window not supported (bash not found in PATH)') let s:warned = 1 @@ -115,6 +113,7 @@ function! fzf#vim#with_preview(...) let preview += ['--preview-window', window] endif if s:is_win + let is_wsl_bash = exepath('bash') =~? 'Windows[/\\]system32[/\\]bash.exe$' let preview_cmd = 'bash '.(is_wsl_bash \ ? substitute(substitute(s:bin.preview, '^\([A-Z]\):', '/mnt/\L\1', ''), '\', '/', 'g') \ : escape(s:bin.preview, '\'))