Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Poweshell profile to combine posh-git and posh-hg prompts
Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)
$profilePath = split-path $profile
# Load posh-git and posh-hg modules from default profile directory
Import-Module $profilePath\posh-git\posh-git
Import-Module $profilePath\posh-hg\posh-hg
function prompt {
Write-Host($pwd) -nonewline
# Git Prompt
$Global:GitStatus = Get-GitStatus
Write-GitStatus $GitStatus
# Mercurial Prompt
$Global:HgStatus = Get-HgStatus
Write-HgStatus $HgStatus
return "> "
}
if(-not (Test-Path Function:\DefaultTabExpansion)) {
Rename-Item Function:\TabExpansion DefaultTabExpansion
}
# Set up tab expansion and include hg expansion
function TabExpansion($line, $lastWord) {
$lastBlock = [regex]::Split($line, '[|;]')[-1]
switch -regex ($lastBlock) {
# mercurial and tortoisehg tab expansion
'(hg|hgtk) (.*)' { HgTabExpansion($lastBlock) }
# Execute git tab completion for all git-related commands
'git (.*)' { GitTabExpansion $lastBlock }
# Fall back on existing tab expansion
default { DefaultTabExpansion $line $lastWord }
}
}
Enable-GitColors
Pop-Location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.