0

Currently the default shell nvim uses is cmd.exe I tried changing it by setting shell to powershell in my nvim config but that didn't work, so I tried this command in the nvim command line:

:let &shell = 'path/to/powershell.exe'

Echo shell command output the powershell path and when I executed :terminal it opened a powershell tab but after quitting and reopening nvim it was still using cmd.exe

How do I permanently change the default shell to powershell?

2 Answers 2

1

Permanently means puting it in your _vimrc. Open it (or create it if it doesn't exist yet) and add the line

set shell=path/to/powershell.exe

or maybe

let &shell = 'path/to/powershell.exe'

You may need to ajust some other parameters also: shellcmdflag, shellquote, shellxquote, shellpipe, shellredir, etc. For example, something like:

set shellcmdflag=-NoLogo\ -NoProfile\ -ExecutionPolicy RemoteSigned\ -Command\ [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;
4
  • Maybe could copy the line to put in _vimrc to make the answer more clear? Jan 3, 2023 at 17:14
  • 1
    Sorry, I though it was obvious (i.e. OP says "I know how to change the option, but I want it to remain permanently now" so i reply to put it in the rc where so that it will be loaded everytime) I'll update the answer as you've requested
    – gildux
    Jan 3, 2023 at 20:43
  • 1
    Understandable :-) But I believe your new version will be more useful to others ;-) Jan 3, 2023 at 21:07
  • Good catch: i forgot that many oter people would read later. Thanks for pointing that out.
    – gildux
    Jan 3, 2023 at 21:15
0

I don't have access to a windows computer or powershell atm. Also my rep is too low to add this as a comment. But have you set everything mentioned in :help shell-powershell?

Also there is/was a issue with setting the default shell for neovim, see the gh issue. If everything is set as in the help command and still no success then you could try the workaround posted in th gh issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.