Skip to content

Instantly share code, notes, and snippets.

@JeremySkinner
Created January 25, 2012 23:32
Show Gist options
  • Save JeremySkinner/1679668 to your computer and use it in GitHub Desktop.
Save JeremySkinner/1679668 to your computer and use it in GitHub Desktop.
Custom Powershell profile that uses both posh-git and posh-hg
$myDir = Split-Path -Parent $MyInvocation.MyCommand.Path
Import-Module "$mydir\posh-hg\posh-hg"
Import-Module "$mydir\posh-git\posh-git"
function prompt {
write-host "$pwd" -NoNewLine -foregroundcolor green
$Global:GitStatus = Get-GitStatus
Write-GitStatus $GitStatus
Write-HgStatus
write-host "»" -NoNewLine -ForegroundColor green
$Host.UI.RawUI.WindowTitle = $pwd
return ' '
}
if(-not (Test-Path Function:\DefaultTabExpansion)) {
Rename-Item Function:\TabExpansion DefaultTabExpansion
}
function TabExpansion($line, $lastWord) {
$LineBlocks = [regex]::Split($line, '[|;]')
$lastBlock = $LineBlocks[-1]
switch -regex ($lastBlock) {
'(git|tgit) (.*)' { gitTabExpansion($lastBlock) }
'(hg|thg) (.*)' { HgTabExpansion($lastBlock) }
# Fall back on existing tab expansion
default { DefaultTabExpansion $line $lastWord }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment