Setting Up Powershell Core in Visual Studio Code for macOS

PowerShell + macOS + VS Code = Heart

Things we need:

  1. Apple computer/laptop running macOS 10.14 (yes, the expensive one)
  2. Ruby (it’s pre-installed on macOS, I have 2.3 pre-installed)
  3. Homebrew
  4. Visual Studio Code
  5. Patience to do this :)

If you are NOT a newbie, jump to Step 4.

1. Installing Homebrew

Open Terminal and copy the link from the Homebrew website, this will install all the necessary packages and everything nice. Easy as.

2. Installing Visual Studio Code

Goto Visual Studio Code website, click on the big, obvious, button to download the DMG package. Open the package and copy it to Application folder. Again, easy as.

3. Installing PowerShell Core

Open Terminal and type in

brew cask install powershell

this should install the latest PowerShell Core, you can test it by typing in pwsh in your Terminal.

Tadaaaaa..!!

4. Setting up VSCode to use PowerShell

The easy way to set this up is by adding the code (below) to your settings.json file (remove the curly braces before adding). you can find this in Command+,.

{
  "powershell.powerShellExePath": "/usr/local/microsoft/powershell/6/pwsh",
  "terminal.integrated.shell.osx": "/usr/local/bin/pwsh",
  "terminal.integrated.shellArgs.osx": []
}

Note: /usr/local/microsoft/powershell/6/pwsh and /usr/local/bin/pwsh is the same.

By default, "terminal.integrated.shellArgs.osx": [] has "terminal.integrated.shellArgs.osx": ["-l"], this gives out error.

Copyright © Akshay Raj Gollahalli's logo 2019