Good news! PowerShell Core installs on Windows, OS X, and Linux. I made it my default in Terminal on OS X. Here’s how.
I tested this on OS X Catalina (10.15) with PowerShell Core 7.
brew install powershell
Then open Terminal, select Terminal > Preferences in the menu, and set shells to open with
Now quit and re-open Terminal. Boom! 💥 You’re standardized on PowerShell.
PowerShell exposes an Environment Provider that works like a filesystem drive. That’s where your path is set:
PS /Users/adam> Get-Item Env:PATH Name Value ---- ----- PATH /usr/local/microsoft/powershell/7:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
When I wrote this, the docs gave examples that used both
Env:Path, but neither worked on OS X. I had to use
Env:PATH. It’s tricky because creating the wrong one doesn’t cause errors it just doesn’t do what you want.
The second gotcha was easier. In Windows the separator is
; so that’s what most examples use, but in OS X it’s
:. I was copy/pasting from Windows code samples before I noticed the problem.
Just like Linux, modifications to
Env:PATH are specific to your session. They’re lost on exit. We can make them permanent. First, find your PowerShell profile:
PS /Users/adam> $PROFILE /Users/adam/.config/powershell/Microsoft.PowerShell_profile.ps1
Create that path and file if it doesn’t exist. Put this command in the
$Env:PATH += ":/Users/adam/opt/path"
Now quit and re-open Terminal and your path should be up to date:
PS /Users/adam> Get-Item Env:PATH Name Value ---- ----- PATH /usr/local/microsoft/powershell/7:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/adam/opt/path
Need more than just this article? We’re available to consult.
You might also want to check out these related articles: