Skip to content

enhancement: add option for using Powershell as shell #1788

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions