Skip to content

Instantly share code, notes, and snippets.

@mirez
Created December 27, 2018 17:39
Show Gist options
  • Save mirez/aca3369d8a08a8c0895691f9f0835267 to your computer and use it in GitHub Desktop.
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
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