Skip to content

Instantly share code, notes, and snippets.

@vcaraulean
Created August 17, 2010 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vcaraulean/532094 to your computer and use it in GitHub Desktop.
Save vcaraulean/532094 to your computer and use it in GitHub Desktop.
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