mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-01 12:42:01 -07:00
[vim/windows] Use chcp only if sed is in PATH
https://github.com/junegunn/vim-plug/pull/891
This commit is contained in:
@@ -50,14 +50,16 @@ if s:is_win
|
|||||||
" Use utf-8 for fzf.vim commands
|
" Use utf-8 for fzf.vim commands
|
||||||
" Return array of shell commands for cmd.exe
|
" Return array of shell commands for cmd.exe
|
||||||
function! s:wrap_cmds(cmds)
|
function! s:wrap_cmds(cmds)
|
||||||
|
let use_chcp = executable('sed')
|
||||||
return map([
|
return map([
|
||||||
\ '@echo off',
|
\ '@echo off',
|
||||||
\ 'setlocal enabledelayedexpansion',
|
\ 'setlocal enabledelayedexpansion']
|
||||||
\ 'for /f "tokens=*" %%a in (''chcp'') do for %%b in (%%a) do set origchcp=%%b',
|
\ + (use_chcp ? [
|
||||||
\ 'chcp 65001 > nul'
|
\ 'for /f "usebackq" %%a in (`chcp ^| sed "s/[^0-9]//gp"`) do set origchcp=%%a',
|
||||||
\ ]
|
\ 'chcp 65001 > nul'] : [])
|
||||||
\ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds])
|
\ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds])
|
||||||
\ + ['chcp !origchcp! > nul', 'endlocal'],
|
\ + (use_chcp ? ['chcp !origchcp! > nul'] : [])
|
||||||
|
\ + ['endlocal'],
|
||||||
\ 'v:val."\r"')
|
\ 'v:val."\r"')
|
||||||
endfunction
|
endfunction
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user