Skip to content

Instantly share code, notes, and snippets.

@Iristyle
Created August 29, 2011 15:20
Show Gist options
  • Save Iristyle/1178601 to your computer and use it in GitHub Desktop.
Save Iristyle/1178601 to your computer and use it in GitHub Desktop.
Mercurial Powershell Prompt
Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)
# Load posh-hg module from current directory
#Import-Module .\posh-hg
# If module is installed in a default location ($env:PSModulePath),
# use this instead (see about_Modules for more information):
Import-Module posh-hg
# Set up a simple prompt, adding the hg prompt parts inside hg repos
function prompt {
Write-Host($pwd) -nonewline
# 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|thg) (.*)' { HgTabExpansion($lastBlock) }
# Fall back on existing tab expansion
default { DefaultTabExpansion $line $lastWord }
}
}
Pop-Location
function Get-Batchfile ($file) {
$cmd = "`"$file`" & set"
cmd /c $cmd | Foreach-Object {
$p, $v = $_.split('=')
Set-Item -path env:$p -value $v
}
}
function VsVars32($version = "10.0")
{
if ([intptr]::size -eq 8)
{
$key = "HKLM:SOFTWARE\Wow6432Node\Microsoft\VisualStudio\" + $version
}
else
{
$key = "HKLM:SOFTWARE\Microsoft\VisualStudio\" + $version
}
$VsKey = get-ItemProperty $key
$VsInstallPath = [System.IO.Path]::GetDirectoryName($VsKey.InstallDir)
$VsToolsDir = [System.IO.Path]::GetDirectoryName($VsInstallPath)
$VsToolsDir = [System.IO.Path]::Combine($VsToolsDir, "Tools")
$BatchFile = [System.IO.Path]::Combine($VsToolsDir, "vsvars32.bat")
Get-Batchfile $BatchFile
[System.Console]::Title = "Visual Studio " + $version + " Windows Powershell"
Set-ConsoleIcon "c:\users\eps\Documents\AwesomeVSIconsYouShouldNotHave\vspowershell.ico"
}
Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)
# DotSource the Console Icon Stuff
. ./Set-ConsoleIcon.ps1
Pop-Location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment