1
1
Fork 0

Show current git branch if we are not on master.

This commit is contained in:
Jonathan Schleifer 2012-03-26 22:57:19 +00:00
parent b53ace0463
commit 923d897c53

52
zshrc
View file

@ -14,16 +14,6 @@ LS_COLOUR="auto"
LS_ON_CD="yes"
LS_ON_INIT="no"
FEMALE="no" # Whether the user is female ;)
if [ "$FEMALE" = "yes" ]; then
PS1="%m:%c%B%(!.#.%{$(print "\e[1;35m")%}♥%{$(print "\e[0m")%})%b "
else
PS1="%m:%c%B%(!.#.$)%b "
fi
PS2="%B>%b "
RPS1="%(1j.%{$(print "\e[1;33m")%}%j%{$(print "\e[0m")%}.)"
RPS1+="%(?..%(1j. .)%{$(print "\e[1;31m")%}%?%{$(print "\e[0m")%})"
RPS2="%(1_.%{$(print "\e[1;30m")%}(%_%)%{$(print "\e[0m")%}.)"
LISTMAX=32768
WORDCHARS="*?[];!#~"
@ -76,13 +66,45 @@ else
}
fi
set_prompt() {
if [ "$FEMALE" = "yes" ]; then
PS1="%m:%c$@%B%(!.#.%{$(print "\e[1;35m")%}♥"
PS1+="%{$(print "\e[0m")%})%b "
else
PS1="%m:%c$@%B%(!.#.$)%b "
fi
PS2="%B>%b "
RPS1="%(1j.%{$(print "\e[1;33m")%}%j%{$(print "\e[0m")%}.)"
RPS1+="%(?..%(1j. .)%{$(print "\e[1;31m")%}%?%{$(print "\e[0m")%})"
RPS2="%(1_.%{$(print "\e[1;30m")%}(%_%)%{$(print "\e[0m")%}.)"
}
set_prompt
_precmd() {
update_terminal_cwd
local branch_name
branch_name="$(git symbolic-ref HEAD 2>/dev/null)"
branch_name="${branch_name##refs/heads/}"
if [ ! -z "$branch_name" -a "$branch_name" != "master" ]; then
local branch
branch="%{$(print "\e[1;30m")%}("
branch+="%{$(print "\e[0;36m")%}$branch_name"
branch+="%{$(print "\e[1;30m")%})%{$(print "\e[0m")%}"
set_prompt "$branch"
else
set_prompt
fi
}
case $TERM in
aterm|Eterm|rxvt*|uxterm*|xterm*)
# Use set_title if you want to change the term title
set_title() {
# Without this, precmd would override it
precmd() {
update_terminal_cwd
_precmd
}
print -Pn "\e]0;$@\a"
}
@ -90,12 +112,17 @@ case $TERM in
unset_title() {
precmd() {
print -Pn "\e]0;%m\a"
update_terminal_cwd
_precmd
}
}
unset_title
;;
*)
precmd() {
_precmd
}
;;
esac
alias vi="vim"
@ -172,4 +199,3 @@ alias -s app=open
unset AUDIO_PLAYER VIDEO_PLAYER
unset ARCHIVE_FORMATS AUDIO_PLAYER_FORMATS VIDEO_PLAYER_FORMATS
unset FGREP FGREP_COLOUR GREP GREP_COLOUR LS LS_COLOUR LS_ON_CD LS_ON_INIT
unset FEMALE