Last active
December 25, 2015 06:09
-
-
Save ishisaka/6930183 to your computer and use it in GitHub Desktop.
posh-gitのコマンドプロンプトを変更
This file contains hidden or 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) | |
# Load posh-git module from current directory | |
Import-Module .\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 | |
# Write-Host($pwd.Drive.Root.ToString() + '..\' + (Split-Path (Split-Path ($pwd.ProviderPath) -Parent) -Leaf) + '\' + (Split-Path ($pwd.ProviderPath) -Leaf)) -nonewline | |
$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-Host($pwd.ProviderPath) -nonewline | |
Write-VcsStatus | |
$global:LASTEXITCODE = $realLASTEXITCODE | |
return "> " | |
} | |
Enable-GitColors | |
Pop-Location | |
Start-SshAgent -Quiet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment