Skip to content

Instantly share code, notes, and snippets.

@mirubid
Last active February 11, 2021 22:41
Show Gist options
  • Save mirubid/769fc5ed178e9358ee30a43c729e8d29 to your computer and use it in GitHub Desktop.
Save mirubid/769fc5ed178e9358ee30a43c729e8d29 to your computer and use it in GitHub Desktop.
My Posh Git Profile
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