Skip to content

Instantly share code, notes, and snippets.

@PatrickJS
Last active December 16, 2015 18:09
Show Gist options
  • Save PatrickJS/5475827 to your computer and use it in GitHub Desktop.
Save PatrickJS/5475827 to your computer and use it in GitHub Desktop.
Bash Profile
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "git:("${ref#refs/heads/}$(num_git_commits_ahead)")"
}
function num_git_commits_ahead {
num=$(git status 2> /dev/null \
| grep "Your branch is ahead of" \
| awk '{split($0,a," "); print a[9];}' 2> /dev/null) || return
if [[ "$num" != "" ]]; then
echo "+$num"
fi
}
function path(){
old=$IFS
IFS=:
printf "%s\n" $PATH
IFS=$old
}
export PATH="~/bin:$PATH"
export EDITOR='subl -w'
export PS1="\e[1;32m\$(parse_git_branch)\e[m\n\u@\h:\w \$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment