While I am using more and more macOS and PowerShell, the need of enriching the look-and-feel starts to reveal. So in this post, I will show you how to properly configure PowerShell with Oh My Posh as your default shell on macOS.
I won’t waste too much time here, as Microsoft already has an excellent article with popular options. Personally I used Homebrew,
brew install --cask powershell
Now at terminal check where PowerShell is installed to,
On my machine, the output is
/usr/local/bin/pwsh. We will use this value later.
Make sure you have
~/.config/powershell/profile.ps1 created, and it contains a line similar to,
$(/opt/homebrew/bin/brew shellenv) | Invoke-Expression
Your machine might require a path other than
/opt/homebrew/bin/brew. Learn the right path to use from the output of
brew install --cask powershell.
Oh My Posh requires a modern terminal (that supports Nerd Fonts), so we need to install iTerm2 now,
brew install --cask iterm2
Oh My Posh themes usually require Nerd Fonts to render its efforts, so here we install Meslo Nerd Font
brew tap homebrew/cask-fonts && brew install --cask font-meslo-lg-nerd-font
In case you prefer another font, search its installation command from here,
Now we can open iTerm2 and its Preferences.
Under Profiles, create a new Profile called PowerShell.
For this profile, set its Command as
/usr/local/bin/pwsh -l -nol.
-nolsuppresses the copyright banner.
-lloads the login profiles (including environment variables). Without this many commands might not be found (such as
codefor VS Code).
More on pwsh arguments can be found in this article.
Under Text section, choose MesloLGM Nerd Font Mono.
Use “Set as Default” menu item from “Other Actions” dropdown to set PowerShell as default profile.
With Homebrew, the installation is still simple,
brew install jandedobbeleer/oh-my-posh/oh-my-posh
Learn the installation path of Oh My Posh via,
brew --prefix oh-my-posh
Once installation finishes, open
~/.config/powershell/profile.ps1 and add another line,
oh-my-posh init pwsh --config /opt/homebrew/opt/oh-my-posh/themes/cloud-native-azure.omp.json | Invoke-Expression
Now open a new tab in iTerm2 and you should see your PowerShell prompt with cloud-native-azure theme.
In case you want to preview different themes quickly, run
If you plan to set PowerShell as default shell in VS Code terminal, make sure that you use the following settings,
"terminal.integrated.fontFamily": "MesloLGM Nerd Font Mono"
Now you can keep iTerm2 in Dock and easily open a terminal with PowerShell for everyday usage, instead of the default Terminal.
To learn Oh My Posh on Windows, you can always trust Scott Hanselman.