Last active
February 11, 2021 22:41
-
-
Save mirubid/769fc5ed178e9358ee30a43c729e8d29 to your computer and use it in GitHub Desktop.
My Posh Git Profile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module posh-git | |
function List-BranchDesc() | |
{ | |
<# | |
.SYNOPSIS | |
list the branch name and description for all branches | |
#> | |
git branch --list | | |
%{$_ -replace "[\* ]",""} | | |
%{$desc=(git config branch.$_.description);write-host "$_ $desc";} | |
} | |
function Get-BranchDesc() | |
{ | |
<# | |
.SYNOPSIS | |
print the description for the current git branch | |
#> | |
git branch --show-current | | |
%{$_ -replace "[\* ]",""} | | |
%{$desc=(git config branch.$_.description);$desc} | |
} | |
function Set-BranchDesc( | |
# the text for the branch description | |
[Parameter(Mandatory = $true)] | |
[String] | |
$msg | |
){ | |
<# | |
.SYNOPSIS | |
set a description for the current git branch | |
.EXAMPLE | |
Set-BranchDesc 'some important changes' | |
#> | |
$branch = (git branch --show-current) | |
git config branch.$branch.description $msg | |
} | |
$GitPromptSettings.DefaultPromptSuffix = '$(Get-BranchDesc)$()$(''>'' * ($nestedPromptLevel + 1))' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment