Question:
How can I configure windows terminal to launch Powershell with a separate profile other than my standard $Profile
?
This would be helpful to have import modules like posh-git
and psreadline
only in the Powershell instance that I launch from wt.exe
rather than from pwsh.exe
Answer:
You can source a custom Powershell (.ps1
) profile file as you invoke pwsh.exe
or powershell.exe
from wt.exe
. For example a posh-git
profile in Windows Terminal settings.json Would look something like this:
1 2 3 4 5 6 7 8 9 |
{ "guid": "{01463d52-dda9-4109-b03f-c55899b52df2}", "name": "Powershell - Posh Git", "commandline": "powershell.exe -noprofile -noexit -command \"invoke-expression '. ''C:/PsProfilePoshGit.ps1''' \"", "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png", "hidden": false }, |
You can generate a unique guid for each new profile you add by running the command [guid]::NewGuid()
in Powershell.
Finally your dedicated Powershell profile file: C:/PsProfilePoshGit.ps1
would look something like this (at a minimum):
1 2 3 4 5 6 7 8 |
Import-Module posh-git function global:prompt { Write-Host -Object "Posh-Git" -NoNewline -ForegroundColor Magenta return "> " } |