aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.bash_prompt14
-rw-r--r--README.md1
2 files changed, 9 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\]"
diff --git a/README.md b/README.md
index 102092b..e412d51 100644
--- a/README.md
+++ b/README.md
@@ -110,5 +110,6 @@ Suggestions/improvements
* [Sindre Sorhus](http://sindresorhus.com/)
* [Tom Ryder](http://blog.sanctum.geek.nz/) and his [dotfiles repository](https://github.com/tejr/dotfiles)
* [Kevin Suttle](http://kevinsuttle.com/) and his [dotfiles repository](https://github.com/kevinSuttle/dotfiles) and [OSXDefaults project](https://github.com/kevinSuttle/OSXDefaults), which aims to provide better documentation for [`~/.osx`](http://mths.be/osx)
+* [Haralan Dobrev](http://hkdobrev.com/)
* anyone who [contributed a patch](https://github.com/mathiasbynens/dotfiles/contributors) or [made a helpful suggestion](https://github.com/mathiasbynens/dotfiles/issues)