-
-
Notifications
You must be signed in to change notification settings - Fork 809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bust up Write-GitStatus into smaller functions to make it easier for individuals to override parts of the status display #345
Comments
This is also related to #304 and Jaykul/PowerLine#1. More modularity and customizability in how the prompt displays would be awesome. And if we do it right, it seems like an opportunity to remove a bunch of clutter from function Write-GitStatus ($GitStatus) {
Write-Prompt ' [' -ForegroundColor Yellow # No need for Before settings
Write-GitBranchStatus $GitStatus
Write-GitFileStatus $GitStatus
Write-GitLocalStatus $GitStatus
Write-Prompt ']' -ForegroundColor Yellow # No need for After settings
} And to customize: function Write-GitStatus ($GitStatus) {
Write-Prompt ' {'
Write-GitBranchStatus $GitStatus -AheadBehindDisplay Compact -GoneText ''
# No need for EnableFileStatus; just don't call Write-GitFileStatus
Write-GitLocalStatus -StagedText ''
Write-GitStashStatus -Before ' (' -After '(' -ForegroundColor Red
Write-Prompt '}'
} |
I've implemented this on branch - https://github.com/dahlbyk/posh-git/tree/rkeithhill/refactor-write-prompt This branch is a branch off of the At the moment, each of the broken up Write-* functions internally uses $GitPromptSettings. This is primarily for it know the symbol and colors to use. That said, we could update these functions to take that information. So currently your function would look like: $global:GitPromptSettings.BranchBehindAndAheadDisplay = 'Compact'
$global:GitPromptSettngs.StashColor.ForegroundColor = 'Red'
$global:GitPromptSettngs.BeforeStashText.ForegroundColor = 'Red'
$global:GitPromptSettngs.AfterStashText.ForegroundColor = 'Red'
function Write-MyGitStatus ($GitStatus) {
Write-Prompt ' {'
Write-GitBranchStatus $GitStatus
Write-GitWorkingDirStatus $GitStatus
Write-Prompt ' ('
Write-GitStashCount $GitStatus
Write-Prompt ')}'
} BTW should we use |
Fixed via PR #513 |
I see a number of PRs come across to change the Git status summary display for things that probably don't apply to that many folks. And folks can today write their own prompt function to take the information from
Get-GitStatus
to display the Git status summary, plus any additional information in anyway they would like. However, in many cases folks just want to tweak one area of the Git status summary info. With this in mind, we should break up the bits and pieces ofWrite-GitStatus
into reusable functions.Perhaps we have
Write-GitStatus
call down toWrite-BranchStatus
,Write-GitIndexStatus
, andWrite-GitWorkingDirStatus
.In one PR scenario the OP wants to display any tags associated with HEAD. In this case, the OP could create his own version of Write-BranchStatus to display tags. Then in his prompt function he could call
Write-GitIndexStatus
andWrite-GitWorkingDirStatus
to create the rest of the status summary text. This would make overriding an individual status summary section much easier.You could make the functions even finer grained as well. Perhaps break down
Write-BranchStatus
intoWrite-BranchName
andWrite-BranchSyncStatus
?The text was updated successfully, but these errors were encountered: