Skip to content

enhancement: add option for using Powershell as shell #1788

@eamonburns

Description

@eamonburns

In neovim/neovim#36881, documentation was added to show how to use powershell.exe (or pwsh.exe) as the shell. I have ported the VimScript to Lua:

if vim.fn.has("win32") == 1 then
  vim.o.shelltemp = false
  local shellcmdflag = "-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command "
  shellcmdflag = shellcmdflag .. "[Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();"
  shellcmdflag = shellcmdflag .. "$PSDefaultParameterValues['Out-File:Encoding']='utf8';"
  vim.o.shellpipe = "> %s 2>&1"
  vim.o.shellquote = ""
  vim.o.shellxquote = ""

  if vim.fn.executable("pwsh.exe") == 1 then
    vim.o.shell = "pwsh.exe"
    shellcmdflag = shellcmdflag .. "$PSStyle.OutputRendering = 'PlainText';"
    vim.env.__SuppressAnsiEscapeSequences = "1"
  else
    vim.o.shell = "powershell.exe"
  end
  vim.o.shellcmdflag = shellcmdflag
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions