Index: zshrc ================================================================== --- zshrc +++ zshrc @@ -12,20 +12,10 @@ LS="gls" 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="*?[];!#~" bindkey -e setopt no_bg_nice @@ -73,30 +63,67 @@ } else update_terminal_cwd() { } 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" } unset_title() { precmd() { print -Pn "\e]0;%m\a" - update_terminal_cwd + _precmd } } unset_title + ;; + *) + precmd() { + _precmd + } ;; esac alias vi="vim" @@ -170,6 +197,5 @@ [ "$LS_ON_INIT" = "yes" ] && ls 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