Skip to content

Instantly share code, notes, and snippets.

@urbanautomaton
Last active December 15, 2015 05:09
Show Gist options
  • Save urbanautomaton/5206496 to your computer and use it in GitHub Desktop.
Save urbanautomaton/5206496 to your computer and use it in GitHub Desktop.
Faster version of __git_ps1 if you only want current branch
#!/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