--- /dev/null
+# zshrc/85_git_prompt
+#
+# Make git information available to the prompt
+#
+# Copyright © 1994–2008 martin f. krafft <madduck@madduck.net>
+# Released under the terms of the Artistic Licence 2.0
+#
+# Source repository: http://git.madduck.net/v/etc/zsh.git
+#
+# Shamelessly adapted from http://www.jukie.net/~bart/conf/zsh.d/S55_git
+#
+
+_get_git_cur_branch() {
+ git branch --no-color | sed -rne 's,^\* ,,p'
+}
+
+_is_git_repo() {
+ [ $(git rev-parse --is-inside-work-tree) = true ]
+}
+
+_set_git_psvar() {
+ if _is_git_repo; then
+ psvar[1]="$(_get_git_cur_branch)"
+ else
+ unset "psvar[1]"
+ fi
+}
+
+update_git_vars_if_git_ran() {
+ # if the last command included the word git, the branch may have changed.
+ # checkout should be alright, but you never know...
+ case "$(history $(($HISTCMD - 1)))" in
+ *git*) _set_git_psvar;;
+ esac
+}
+precmd_functions+=update_git_vars_if_git_ran
+
+update_git_vars() {
+ _set_git_psvar
+}
+chpwd_functions+=update_git_vars
+
+# call it once
+update_git_vars
+
+# vim:ft=zsh
is_root && PS1_HL=U
PS1="%${PS1_HL:=B}%m%${(L)PS1_HL}:%25<..<%~%# "
unset PS1_HL
-RPS1="#[%(0?..%?,)%!]%v"
+RPS1="#%(1v.%1v,.)%(0?..%?,)%!"
# vim:ft=zsh