public
Created

Color Shell prompt with git repo information

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 
# Git branch in prompt.
parse_git_branch()
{
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/';
}
 
parse_git_tag ()
{
git describe --tags 2> /dev/null
}
parse_git_branch_or_tag()
{
local OUT="$(parse_git_branch)"
if [ "$OUT" == " ((no branch))" ]; then
OUT=" [$(parse_git_tag)] ";
fi
echo " $OUT "
}
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\[\033[32m\]\$(parse_git_branch_or_tag)\[\033[00m\]\$ "
 
export CLICOLOR=1
# export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.