1 function theme_precmd {
5 local promptsize=${#${(%):--(%n@%M:)--(%l)-}}
6 local pwdsize=${#${(%):-%~}}
7 local gitbranchsize="${#${(%)$(git_prompt_info)}:-}"
8 local rvmpromptsize="${#${(%)$(ruby_prompt_info):-}}"
10 # Truncate the path if it's too long.
11 if (( promptsize + pwdsize + rvmpromptsize + gitbranchsize > COLUMNS )); then
12 (( PR_PWDLEN = COLUMNS - promptsize ))
14 PR_FILLBAR="\${(l.$(( COLUMNS - (promptsize + pwdsize + rvmpromptsize + gitbranchsize) ))..${PR_SPACE}.)}"
18 function theme_preexec {
19 setopt local_options extended_glob
20 if [[ "$TERM" == "screen" ]]; then
21 local CMD=${1[(wr)^(*=*|sudo|-*)]}
25 if [[ "$TERM" == "xterm" ]]; then
29 if [[ "$TERM" == "rxvt" ]]; then
35 autoload -U add-zsh-hook
36 add-zsh-hook precmd theme_precmd
37 add-zsh-hook preexec theme_preexec
42 # Need this so the prompt will work.
45 # See if we can use colors.
47 for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE GREY; do
48 typeset -g PR_$color="%{$terminfo[bold]$fg[${(L)color}]%}"
49 typeset -g PR_LIGHT_$color="%{$fg[${(L)color}]%}"
51 PR_NO_COLOUR="%{$terminfo[sgr0]%}"
53 # Use extended characters to look nicer
61 ZSH_THEME_GIT_PROMPT_PREFIX=" ["
62 ZSH_THEME_GIT_PROMPT_SUFFIX="]"
65 ZSH_THEME_RUBY_PROMPT_PREFIX=" ["
66 ZSH_THEME_RUBY_PROMPT_SUFFIX="]"
68 # Decide if we need to set titlebar text.
71 PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%M:%~ $(git_prompt_info) $(ruby_prompt_info) | ${COLUMNS}x${LINES} | %y\a%}'
74 PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
81 # Decide whether to set a screen title
82 if [[ "$TERM" == "screen" ]]; then
83 PR_STITLE=$'%{\ekzsh\e\\%}'
88 # Finally, the prompt.
89 PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
91 $PR_BLUE%(!.$PR_RED%SROOT%s.%n)$PR_GREEN@$PR_BLUE%M:$PR_GREEN%$PR_PWDLEN<...<%~$PR_CYAN$(git_prompt_info)$(ruby_prompt_info)\
92 $PR_RED>$PR_HBAR${(e)PR_FILLBAR}\
94 $PR_GREEN%l$PR_RED>$PR_HBAR\
97 %(?..$PR_LIGHT_RED%?$PR_BLUE:)\
98 $PR_LIGHT_BLUE%(!.$PR_RED.$PR_WHITE)%#$PR_RED>$PR_HBAR\