Skip to content

Instantly share code, notes, and snippets.

@mauricerenck
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauricerenck/e36b9d7807f463f76121 to your computer and use it in GitHub Desktop.
Save mauricerenck/e36b9d7807f463f76121 to your computer and use it in GitHub Desktop.
[sh] show current branch in bash-prompt
#!/bin/bash
## git bash-prompt
GIT_THEME_PROMPT_DIRTY='*'
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo -e "(${ref#refs/heads/}$(parse_git_dirty))"
}
function parse_git_dirty {
if [[ -n $(git status -s 2> /dev/null |grep -v ^# | grep -v "working directory clean" ) ]]; then
echo -e "$GIT_THEME_PROMPT_DIRTY"
else
echo -e "$GIT_THEME_PROMPT_CLEAN"
fi
}
# Tell ls to be colourful
export CLICOLOR=1
export LSCOLORS=Exfxcxdxbxegedabagacad
PS1="\[\033[1;33m\]\W\[\033[0m\] \[\033[1;32m\]\[\$(git_prompt_info)\]\[\033[0m\]$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment