Skip to content

Commit

Permalink
Using different color for git branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Tsai authored and Thomas Tsai committed Jul 8, 2014
1 parent 0b1860f commit 7af082a
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .bashrc
Expand Up @@ -43,9 +43,19 @@ alias sdcv='sdcv -n'
function parse_git_branch { function parse_git_branch {
branch=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/') branch=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')
url=$(git remote show -n origin 2> /dev/null | sed -n 's/Fetch URL:\ //p') url=$(git remote show -n origin 2> /dev/null | sed -n 's/Fetch URL:\ //p')
[ -n "${branch}" ] && [ -n "${url}" ] && echo "$url->$branch" [ -n "${branch}" ] && [ -n "${url}" ] && echo "$url->$branch"
} }


function git_url {
url=$(git remote show -n origin 2> /dev/null | sed -n 's/Fetch URL:\ //p')
[ -n "${url}" ] && echo "$url"
}

function git_branch {
branch=$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/')
[ -n "${branch}" ] && echo "$branch"
}

# set a fancy prompt (non-color, unless we know we "want" color) # set a fancy prompt (non-color, unless we know we "want" color)
case "$debian_version" in case "$debian_version" in
6.0.9) 6.0.9)
Expand All @@ -54,7 +64,7 @@ case "$debian_version" in
;; ;;
*) *)
#PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' #PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
PS1='<\[\033[01;32m\]\u@\h-${debian_version}\[\033[00m\]:\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]/\n\T\$>' PS1='<\[\033[01;32m\]\u@\h-${debian_version}\[\033[00m\]:\w\[\033[01;31m\]$(git_url)\[\033[00m\]\[\033[01;33m\]->$(git_branch)\[\033[00m\]/\n\T\$>'
;; ;;
esac esac


Expand Down

0 comments on commit 7af082a

Please sign in to comment.