It is really hard to find a setting in the output of $GitPrompSettings:
LocalWorkingStatusForegroundColor : DarkRed
FileModifiedText : ~
AfterStashBackgroundColor : Black
WorkingForegroundBrightColor : Red
RepositoriesInWhichToDisableFileStatus : {}
IndexForegroundColor : DarkGreen
BranchForegroundColor : Cyan
BeforeStashForegroundColor : Red
EnablePromptStatus : True
AfterBackgroundColor : Black
FileRemovedText : -
BeforeIndexBackgroundColor : Black
AfterText : ]
BeforeForegroundColor : Yellow
LocalWorkingStatusSymbol : !
BranchAheadStatusSymbol : ↑
LocalDefaultStatusSymbol :
IndexForegroundBrightColor : Green
IndexBackgroundColor : Black
LocalStagedStatusForegroundColor : Cyan
ShowStatusWhenZero : True
WorkingForegroundColor : DarkRed
BranchIdenticalStatusToBackgroundColor : Black
BeforeIndexForegroundColor : DarkGreen
BranchIdenticalStatusToSymbol : ≡
BranchBehindAndAheadStatusForegroundColor : Yellow
LocalDefaultStatusForegroundColor : DarkGreen
DescribeStyle :
BranchBackgroundColor : Black
LocalStagedStatusBackgroundColor : Black
BranchIdenticalStatusToForegroundColor : Cyan
AfterStashText : )
BeforeBackgroundColor : Black
BeforeIndexForegroundBrightColor : Green
EnableStashStatus : False
Debug : False
LocalWorkingStatusForegroundBrightColor : Red
LocalWorkingStatusBackgroundColor : Black
LocalStagedStatusSymbol : ~
DelimText : |
BranchBehindAndAheadStatusSymbol : ↕
WorkingBackgroundColor : Black
BeforeStashBackgroundColor : Black
DefaultForegroundColor : Gray
BranchNameLimit : 0
AfterForegroundColor : Yellow
DelimBackgroundColor : Black
BranchBehindStatusForegroundColor : Red
AfterStashForegroundColor : Red
LocalDefaultStatusForegroundBrightColor : Green
LocalDefaultStatusBackgroundColor : Black
StashForegroundColor : Red
DelimForegroundColor : Yellow
TruncatedBranchSuffix : ...
FileAddedText : +
StashBackgroundColor : Black
BranchAheadStatusForegroundColor : Green
BranchUntrackedSymbol :
BranchBehindStatusBackgroundColor : Black
BranchAheadStatusBackgroundColor : Black
AutoRefreshIndex : True
BeforeText : [
BranchBehindStatusSymbol : ↓
EnableWindowTitle : posh~git ~
BranchBehindAndAheadStatusBackgroundColor : Black
BeforeIndexText :
EnableFileStatus : True
BeforeStashText : (
FileConflictedText : !
It would be much easier to find related settings if we used an ordered dictionary which preserves insert order (not available in v2 though):
Name Value
---- -----
DefaultForegroundColor Gray
BeforeText [
BeforeForegroundColor Yellow
BeforeBackgroundColor Black
DelimText |
DelimForegroundColor Yellow
DelimBackgroundColor Black
AfterText ]
AfterForegroundColor Yellow
AfterBackgroundColor Black
FileAddedText +
FileModifiedText ~
FileRemovedText -
FileConflictedText !
LocalDefaultStatusSymbol
LocalDefaultStatusForegroun... DarkGreen
LocalDefaultStatusForegroun... Green
LocalDefaultStatusBackgroun... Black
LocalWorkingStatusSymbol !
LocalWorkingStatusForegroun... DarkRed
LocalWorkingStatusForegroun... Red
LocalWorkingStatusBackgroun... Black
LocalStagedStatusSymbol ~
LocalStagedStatusForeground... Cyan
LocalStagedStatusBackground... Black
BranchUntrackedSymbol
BranchForegroundColor Cyan
BranchBackgroundColor Black
BranchGoneStatusSymbol ×
BranchGoneStatusForegroundC... DarkCyan
BranchGoneStatusBackgroundC... Black
BranchIdenticalStatusToSymbol ≡
BranchIdenticalStatusToFore... Cyan
BranchIdenticalStatusToBack... Black
BranchAheadStatusSymbol ↑
BranchAheadStatusForeground... Green
BranchAheadStatusBackground... Black
BranchBehindStatusSymbol ↓
BranchBehindStatusForegroun... Red
BranchBehindStatusBackgroun... Black
BranchBehindAndAheadStatusS... ↕
BranchBehindAndAheadStatusF... Yellow
BranchBehindAndAheadStatusB... Black
BeforeIndexText
BeforeIndexForegroundColor DarkGreen
BeforeIndexForegroundBright... Green
BeforeIndexBackgroundColor Black
IndexForegroundColor DarkGreen
IndexForegroundBrightColor Green
IndexBackgroundColor Black
WorkingForegroundColor DarkRed
WorkingForegroundBrightColor Red
WorkingBackgroundColor Black
EnableStashStatus False
BeforeStashText (
BeforeStashBackgroundColor Black
BeforeStashForegroundColor Red
AfterStashText )
AfterStashBackgroundColor Black
AfterStashForegroundColor Red
StashBackgroundColor Black
StashForegroundColor Red
ShowStatusWhenZero True
AutoRefreshIndex True
BranchBehindAndAheadDisplay Full
EnablePromptStatus True
EnableFileStatus True
RepositoriesInWhichToDisabl... {}
DescribeStyle
EnableWindowTitle posh~git ~
Debug False
BranchNameLimit 0
TruncatedBranchSuffix ...
And yeah, the ordered dictionary is a different type than a PSCustomObject but you can dot the kv pairs in PowerShell as if it were a property e.g. $GitPromptSettings.EnableFileStatus.
PowerShell v3 has an [ordered] property for PSObject properties, so you can use that too.
Yup, that is exactly what I prototyped the above with. But as you point out, [ordered] isn't available in PS v2 so this change will have to wait until 0.7.0 has been released and we start work on 1.0.0 which will definitely drop support for v2 (and maybe even v3 and 4).
What about grouping related items?
PS> $GitPromptSettings.Colors.Stash.Background = Red
I'm inclined to leave as-is for 0.x and then move to [ordered] for 1.x with either a cleanup of the property names (e.g. BranchIdenticalStatusTo* should be BranchIdenticalToStatus*) or a shift to grouping.
Pondering the grouping... what if we defined a type to encapsulate the common text + foreground + background color pattern. That type's ToString() could even be configured to return the ANSI colorized string so dumping $GitPromptSettings.Format would show the colorized output.
Agreed on 0.x.
One advantage of using [ordered] for 1.x is that I don't think it would be a breaking change - not that I'm necessarily opposed to a breaking change for 1.x if the result is a lot better. :-)
what if we defined a type to encapsulate the common text + foreground + background color pattern
I like that idea but I'm not sure about ToString display a completed prompt. How would that work with the Write-GitStatus decomposition as suggested in #345?
I could see a function like Write-GitBranchStatus $GitStatus having optional Fore/BackgroundColor parameters that default to the corresponding setting in $GitPromptSettings.
I like that idea but I'm not sure about ToString display a completed prompt. How would that work with the Write-GitStatus decomposition as suggested in #345?
I more mean for each of the components, e.g. $GitPromptSettings.Format.BranchStatusIdenticalTo.ToString() would return the colorized identical-to symbol, and dumping $GitPromptSettings.Format would show something like this (but with colors):
Before : [
BranchStatusAhead : ↑
BranchStatusBehindAndAhead : ↕
BranchStatusBehind : ↓
BranchStatusIdenticalTo : ≡
BranchStatusUntracked :
BeforeIndex :
Index : !0 +0 ~0 -0
Delim : |
Working : !0 +0 ~0 -0
LocalDefaultStatus :
LocalStagedStatus : ~
LocalWorkingStatus : !
BeforeStash : (
AfterStash : )
After : ]
Of course, if we go the composition route proposed in #345 then format/color config might go away. Then again, maybe not - I expect more folks wish to just change colors than rearrange the whole prompt?
Gotcha. Probably just need to prototype something up after 0.7. It would be nice to have the above for simple customization and #345 for more significant customization.
.Net 3.5 has System.Collections.Specialized.OrderedDictionary, so it's possible to use that in 0.7 if you want - the syntax won't be as friendly as [ordered] though.
Partially addressed (ordering) by PR #382. By using a PSCustomObject the value can still be accessed using property syntax as if it were a PSObject with dedicated properties when in fact it is a hashtable (which preserves definition order on v5 and higher).
Also, unless I'm missing something, the readme.md on this project is saying that the "most common" customization to the prompt is on a property that doesn't seem to exist:
You can customize the posh-git prompt or define your own custom prompt function. The most common customization for the posh-git provided prompt is to make it span two lines which can be done with the following command:
$GitPromptSettings.DefaultPromptSuffix = 'n$(''>'' * ($nestedPromptLevel + 1)) '
There's no DefaultPromptSuffix property on the GitPromptSettings object.
The master branch of this repo is used for development and represents the state of the next version - 0.7.0. This version is very close to being finished and published, hopefully by early next week.
So should this work when installed using ps-get?
If I do:
Install-Module posh-git -Scope CurrentUser
Import-Module posh-git
$GitPromptSettings.DefaultPromptSuffix = 'n$(''>'' * ($nestedPromptLevel + 1)) '
I get an error:
Exception setting "DefaultPromptSuffix": "The property 'DefaultPromptSuffix' cannot be found on this object. Verify that the property exists and can be set."
should this work
No, because we haven't released 0.7.0 which contains this change. Hang tight, should be released sometime early next week (I hope).
Refactoring this issue to represent the general need to improve the config situation. Ideas:
~/.posh-git.yml or equivalentgit config posh-git.Whatever)I lean towards commands like Get/Set-PoshGitPromptOption (similar to PSReadLine's Get/Set-PSReadlineOption) but depending on whether we support only PS v5 and higher, we might also work PS classes into the mix to group related settings.
Addressed by PR #513
Most helpful comment
What about grouping related items?