docs(options): shell-powershell #36881

Problem:
Current options for powershell and pwsh had mistakes and rationale
behind them was not clear.

Solution:
Update the suggested options by splitting up powershell and pwsh, as
well as ensuring that all options work and rationale is documented and
discussed.
This commit is contained in:
ymich9963
2025-12-10 05:57:16 +00:00
committed by GitHub
parent aeebc51851
commit d2e445e1bd
3 changed files with 50 additions and 19 deletions

View File

@@ -7661,13 +7661,22 @@ local options = {
unescaping, so to keep yourself sane use |:let-&| like shown above.
*shell-powershell*
To use PowerShell: >vim
let &shell = executable('pwsh') ? 'pwsh' : 'powershell'
let &shellcmdflag = '-NoLogo -NonInteractive -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();$PSDefaultParameterValues[''Out-File:Encoding'']=''utf8'';$PSStyle.OutputRendering=''plaintext'';Remove-Alias -Force -ErrorAction SilentlyContinue tee;'
let &shellredir = '2>&1 | %%{ "$_" } | Out-File %s; exit $LastExitCode'
let &shellpipe = '2>&1 | %%{ "$_" } | tee %s; exit $LastExitCode'
set shellquote= shellxquote=
< This option cannot be set from a |modeline| or in the |sandbox|, for
set noshelltemp
let &shell = 'powershell'
let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command '
let &shellcmdflag .= '[Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();'
let &shellcmdflag .= '$PSDefaultParameterValues[''Out-File:Encoding'']=''utf8'';'
let &shellpipe = '> %s 2>&1'
set shellquote= shellxquote=
<
*shell-pwsh*
To use pwsh, use the above settings with `let &shell = 'pwsh'`, and
add: >vim
let &shellcmdflag .= '$PSStyle.OutputRendering = ''PlainText'';'
" Workaround (may not be needed in future version of pwsh):
let $__SuppressAnsiEscapeSequences = 1
<
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.
]=],
expand = true,