nul*_*ser 3 windows vim powershell
我想做一个功能,它执行以下操作
if (vim is running in powershell)
call system("only works in powershell")
else
echo "Skipping powershell command"
Run Code Online (Sandbox Code Playgroud)
有谁知道怎么告诉vim正在运行什么程序?
编辑:echo &term在两种情况下输出"win32".
从我看到你不需要检查运行什么vim.您需要检查值,&shell因为如果&shell选项告诉它在powershell中运行命令,vim将在powershell 中运行命令.如果shell的名称是,posh那么可以使用
if stridx(&shell, 'posh')!=-1
call system('only works in powershell')
else
echo 'Skipping powershell command'
endif
Run Code Online (Sandbox Code Playgroud)
.但我宁愿建议用类似的东西直接运行powershell
call system('posh -c '.shellescape('only works in powershell'))
Run Code Online (Sandbox Code Playgroud)
(注意:我不确定'posh -c '实际上应该是什么字符串)或临时set&shell选项:
let savedsh=[&shell, &shellcmdflag, &shellxquote, &shellxescape, &shellquote, &shellpipe, &shellredir]
set shell=posh shellcmdflag=-c shellxquote=\" shellquote=\" shellpipe=> shellredir=>
try
call system('only works in powershell')
finally
let [&shell, &shellcmdflag, &shellxquote, &shellxescape, &shellquote, &shellpipe, &shellredir]=savedsh
endtry
Run Code Online (Sandbox Code Playgroud)
(再次,不确定选项的确切值):这些方法命令将始终在powershell中运行.
| 归档时间: |
|
| 查看次数: |
856 次 |
| 最近记录: |