Reputation: 141452
My PowerShell profile customizes the prompt and background color.
$Host.UI.RawUI.BackgroundColor = 'Red';
function prompt
{
Write-Host ("PS >") -nonewline -foregroundcolor Magenta
return " "
}
When I open PowerShell, both customizations work:
PS >
When I open Git Shell, only the background color customization works The background is red, but the prompt isn't short.
C:\Users\BigFont\Documents\GitHub>
...and then, if I run . $profile
to explicitly import my profile, the entire customization does work.
PS >
How can I make Git Shell change the prompt without having to explicitly import my profile?
Running $profile | select *
results in
AllUsersAllHosts : C:\Windows\SysWOW64\WindowsPowerShell\v1.0\profile.ps1
AllUsersCurrentHost : C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1
CurrentUserAllHosts : C:\Users\BigFont\Documents\WindowsPowerShell\profile.ps1
CurrentUserCurrentHost : C:\Users\BigFont\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
Running . $profile
does override Posh Gits profile. This is what I want - now I need to determine how to do it without needing to run . $profile
.
Upvotes: 2
Views: 290
Reputation: 47792
One of the main features of posh-git is changing the prompt to show additions, branch, etc. so its customizations are probably running after yours and overwriting them.
By re-importing your profile, you may in fact be undoing posh-git's prompt. To see for sure, re-import your profile and then cd
into a repo.
Also check $profile | select *
to see all of the profiles that may be in effect. It may be best to simply edit posh-git's profile (even if only to dot source your own).
After reading your edits, I would say go ahead and edit each profile until you find the one where posh-git is running from. An easy way to launch a profile in the ISE editor from the console host is to do something like this:
ise $Profile.AllUsersAllHosts
ise $Profile.CurrentUserAllHosts
(etc.)
Note that the profiles may not actually exist. If they don't exist you won't be able to launch it in ISE, which is fine.
Once you find the one where posh-git is making its changes, just dot source your own file at the end.
Alternatively, you can just delete that file or comment the whole thing out.
Let me know if I'm making sense or if this is confusing.
Upvotes: 1