Created
December 27, 2018 17:39
-
-
Save mirez/aca3369d8a08a8c0895691f9f0835267 to your computer and use it in GitHub Desktop.
Powershell to modify prompt to show CWD and append Git repo and branch when applicable to current directory
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
function prompt { | |
$gitstatus = "`r`n » $(pwd)"; | |
$pwd = (pwd); | |
try { | |
$gitbranch = (git rev-parse --abbrev-ref HEAD); | |
$repo = ((git rev-parse --show-toplevel) -split "/") | Select-Object -Last 1 | |
if( -not [string]::IsNullOrEmpty("$gitbranch") ) { | |
$gitstatus = "`r`n$($pwd) | [$repo]/[$gitbranch] " | |
} | |
} | |
finally { | |
} | |
return $gitstatus + " `r`n » "; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment