Last active
December 15, 2015 05:09
-
-
Save urbanautomaton/5206496 to your computer and use it in GitHub Desktop.
Faster version of __git_ps1 if you only want current branch
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
#!/bin/bash | |
function git_ps1_fast() { | |
local dir="$PWD" | |
local git_dir | |
until [[ -z "$dir" ]]; do | |
git_dir="$dir/.git" | |
if [[ -d "$git_dir" ]]; then | |
echo " (`git rev-parse --abbrev-ref HEAD`)" | |
return | |
fi | |
dir="${dir%/*}" | |
done | |
} | |
PS1='\u@\h:\w$(git_ps1_fast) \$' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment