mirror of
https://github.com/junegunn/fzf.vim.git
synced 2026-02-26 19:47:22 +08:00
[fzf#vim#with_preview] Detect WSL bash on Windows only
Close https://github.com/junegunn/fzf.vim/issues/1052
This commit is contained in:
committed by
Junegunn Choi
parent
18205e071d
commit
3348aef05d
@@ -76,8 +76,6 @@ endfunction
|
|||||||
|
|
||||||
" [[spec to wrap], [preview window expression], [toggle-preview keys...]]
|
" [[spec to wrap], [preview window expression], [toggle-preview keys...]]
|
||||||
function! fzf#vim#with_preview(...)
|
function! fzf#vim#with_preview(...)
|
||||||
let bash_path = exepath('bash')
|
|
||||||
let is_wsl_bash = bash_path =~? 'Windows[/\\]system32[/\\]bash.exe$'
|
|
||||||
" Default spec
|
" Default spec
|
||||||
let spec = {}
|
let spec = {}
|
||||||
let window = ''
|
let window = ''
|
||||||
@@ -90,7 +88,7 @@ function! fzf#vim#with_preview(...)
|
|||||||
call remove(args, 0)
|
call remove(args, 0)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if empty(bash_path)
|
if !executable('bash')
|
||||||
if !s:warned
|
if !s:warned
|
||||||
call s:warn('Preview window not supported (bash not found in PATH)')
|
call s:warn('Preview window not supported (bash not found in PATH)')
|
||||||
let s:warned = 1
|
let s:warned = 1
|
||||||
@@ -115,6 +113,7 @@ function! fzf#vim#with_preview(...)
|
|||||||
let preview += ['--preview-window', window]
|
let preview += ['--preview-window', window]
|
||||||
endif
|
endif
|
||||||
if s:is_win
|
if s:is_win
|
||||||
|
let is_wsl_bash = exepath('bash') =~? 'Windows[/\\]system32[/\\]bash.exe$'
|
||||||
let preview_cmd = 'bash '.(is_wsl_bash
|
let preview_cmd = 'bash '.(is_wsl_bash
|
||||||
\ ? substitute(substitute(s:bin.preview, '^\([A-Z]\):', '/mnt/\L\1', ''), '\', '/', 'g')
|
\ ? substitute(substitute(s:bin.preview, '^\([A-Z]\):', '/mnt/\L\1', ''), '\', '/', 'g')
|
||||||
\ : escape(s:bin.preview, '\'))
|
\ : escape(s:bin.preview, '\'))
|
||||||
|
|||||||
Reference in New Issue
Block a user