Skip to content

Instantly share code, notes, and snippets.

@ishisaka
Created May 27, 2016 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ishisaka/a880f0e74fffe208001c31749a06cbbf to your computer and use it in GitHub Desktop.
Save ishisaka/a880f0e74fffe208001c31749a06cbbf to your computer and use it in GitHub Desktop.
Posh-Git Prompt改造
Push-Location (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)
# Load posh-git module from current directory
Import-Module .\Modules\posh-git
# If module is installed in a default location ($env:PSModulePath),
# use this instead (see about_Modules for more information):
# Import-Module posh-git
#Set up a simple prompt, adding the git prompt parts inside git repos
function global:prompt {
$realLASTEXITCODE = $LASTEXITCODE
# # Reset color, which can be messed up by Enable-GitColors
# $Host.UI.RawUI.ForegroundColor = $GitPromptSettings.DefaultForegroundColor
$pro = ''
if ($pwd.ProviderPath.ToString().Length -gt 19) {
if ((Split-Path($pwd.ProviderPath) -Leaf).ToString().Length -gt 16) { #C:\分は削除して
$pro = $pwd.Drive.Name + ':..' + (Split-Path($pwd.ProviderPath) -Leaf)
}
else {
$start = $pwd.ProviderPath.ToString().Length - 16
$pro = $pwd.Drive.Name + ':..' + $pwd.ProviderPath.Substring($start)
}
}
else {
$pro = $pwd.ProviderPath
}
Write-Host($pro) -nonewline
Write-VcsStatus
$global:LASTEXITCODE = $realLASTEXITCODE
return "> "
}
Pop-Location
Start-SshAgent -Quiet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment