Created
August 17, 2010 21:17
-
-
Save vcaraulean/532094 to your computer and use it in GitHub Desktop.
Poweshell profile to combine posh-git and posh-hg prompts
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
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