aboutsummaryrefslogtreecommitdiffstats
path: root/.bash_prompt
diff options
context:
space:
mode:
Diffstat (limited to '.bash_prompt')
-rw-r--r--.bash_prompt14
1 files changed, 8 insertions, 6 deletions
diff --git a/.bash_prompt b/.bash_prompt
index 21c4b4b..83670e5 100644
--- a/.bash_prompt
+++ b/.bash_prompt
@@ -43,13 +43,15 @@ export WHITE
export BOLD
export RESET
-function parse_git_dirty() {
- [[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]] && echo "*"
-}
-
function parse_git_branch() {
- git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
+ local branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
+ if [ -n "${branch}" ]; then
+ [ "${branch}" == "HEAD" ] && local branch=$(git rev-parse --short HEAD 2>/dev/null)
+ local status=$(git status --porcelain 2>/dev/null)
+ echo -n " on ${PURPLE}${branch}"
+ [ -n "${status}" ] && echo -n "*"
+ fi
}
-export PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$([[ -n \$(git branch 2> /dev/null) ]] && echo \" on \")\[$PURPLE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]"
+export PS1="\[${BOLD}${MAGENTA}\]\u \[$WHITE\]at \[$ORANGE\]\h \[$WHITE\]in \[$GREEN\]\w\[$WHITE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]"
export PS2="\[$ORANGE\]→ \[$RESET\]"