Last active
August 29, 2015 14:02
-
-
Save mauricerenck/e36b9d7807f463f76121 to your computer and use it in GitHub Desktop.
[sh] show current branch in bash-prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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