Speedup parse_git_branch()

This commit is contained in:
Michael Campagnaro 2018-06-11 13:53:44 -04:00
parent 1505eeb17d
commit 4e6c65ee9f

View File

@ -1,3 +1,5 @@
#set -x # Print out all of the commands that are executing.
# For Windows setup # For Windows setup
test -f ~/.functions && . ~/.functions test -f ~/.functions && . ~/.functions
test -f ~/.aliases && . ~/.aliases test -f ~/.aliases && . ~/.aliases
@ -21,7 +23,9 @@ export TMPDIR=/tmp
# Customize the shell prompt # Customize the shell prompt
parse_git_branch() { parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' if [[ "$PWD" != "$HOME" ]]; then
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
fi
} }
export PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\] @ \w\[\033[33m\]\n$(parse_git_branch)\[\033[0;32m\]\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\]\[\033[0m\] ' export PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\] @ \w\[\033[33m\]\n$(parse_git_branch)\[\033[0;32m\]\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\]\[\033[0m\] '