Created
August 7, 2017 21:02
-
-
Save jennings/02bcef9547a37702345e177203076f05 to your computer and use it in GitHub Desktop.
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
# Truncate paths in the prompt to 2 characters so long directories don't take up the whole window | |
function Prompt { | |
$path = $ExecutionContext.SessionState.Path.CurrentLocation | |
$segment = Split-path -Leaf $path | |
$path = Split-Path $path | |
$segments = @( $segment ) | |
while ($segment -ne $path -and $path -ne "") { | |
$segment = Split-Path -Leaf $path | |
$path = Split-Path $path | |
if ($path -eq "") { | |
# If the rest of the path is empty, this is the drive | |
# letter and we should just strip the trailing slash | |
$segments += $segment.Substring(0, $segment.Length-1) | |
} elseif ($segment.Length -gt 4) { | |
# If the segment is longer than 4 characters, | |
# trim it to 2 and add ellipses | |
$segments += ($segment.Substring(0, 2) + "…" + $segment.Substring($segment.Length - 1)) | |
} else { | |
# If the segment is 1 or 2 characters, just | |
# show the whole thing | |
$segments += $segment | |
} | |
} | |
[array]::Reverse($segments) | |
$origLASTEXITCODE = $LASTEXITCODE | |
write-host -nonewline "$([string]::Join("\", $segments))" | |
write-vcsstatus | |
$LASTEXITCODE = $origLASTEXITCODE | |
return "$('>' * ($nestedPromptLevel + 1)) " | |
} | |
import-module jump.location | |
import-module posh-git | |
new-alias which Get-Command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment