]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/themes/simonoff.zsh-theme
...
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / themes / simonoff.zsh-theme
1 function theme_precmd {
2   PR_FILLBAR=""
3   PR_PWDLEN=""
4
5   local promptsize=${#${(%):--(%n@%M:)--(%l)-}}
6   local pwdsize=${#${(%):-%~}}
7   local gitbranchsize="${#${(%)$(git_prompt_info)}:-}"
8   local rvmpromptsize="${#${(%)$(ruby_prompt_info):-}}"
9
10   # Truncate the path if it's too long.
11   if (( promptsize + pwdsize + rvmpromptsize + gitbranchsize > COLUMNS )); then
12     (( PR_PWDLEN = COLUMNS - promptsize ))
13   else
14     PR_FILLBAR="\${(l.$(( COLUMNS - (promptsize + pwdsize + rvmpromptsize + gitbranchsize) ))..${PR_SPACE}.)}"
15   fi
16 }
17
18 function theme_preexec {
19   setopt local_options extended_glob
20   if [[ "$TERM" == "screen" ]]; then
21     local CMD=${1[(wr)^(*=*|sudo|-*)]}
22     echo -n "\ek$CMD\e\\"
23   fi
24
25   if [[ "$TERM" == "xterm" ]]; then
26     print -Pn "\e]0;$1\a"
27   fi
28
29   if [[ "$TERM" == "rxvt" ]]; then
30     print -Pn "\e]0;$1\a"
31   fi
32
33 }
34
35 autoload -U add-zsh-hook
36 add-zsh-hook precmd  theme_precmd
37 add-zsh-hook preexec theme_preexec
38
39
40 # Set the prompt
41
42 # Need this so the prompt will work.
43 setopt prompt_subst
44
45 # See if we can use colors.
46 autoload zsh/terminfo
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}]%}"
50 done
51 PR_NO_COLOUR="%{$terminfo[sgr0]%}"
52
53 # Use extended characters to look nicer
54 PR_HBAR="-"
55 PR_ULCORNER="-"
56 PR_LLCORNER="-"
57 PR_LRCORNER="-"
58 PR_URCORNER="-"
59
60 # Modify Git prompt
61 ZSH_THEME_GIT_PROMPT_PREFIX=" ["
62 ZSH_THEME_GIT_PROMPT_SUFFIX="]"
63
64 # Modify RVM prompt
65 ZSH_THEME_RUBY_PROMPT_PREFIX=" ["
66 ZSH_THEME_RUBY_PROMPT_SUFFIX="]"
67
68 # Decide if we need to set titlebar text.
69 case $TERM in
70   xterm*|*rxvt*)
71     PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%M:%~ $(git_prompt_info) $(ruby_prompt_info) | ${COLUMNS}x${LINES} | %y\a%}'
72     ;;
73   screen)
74     PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
75     ;;
76   *)
77     PR_TITLEBAR=""
78     ;;
79 esac
80
81 # Decide whether to set a screen title
82 if [[ "$TERM" == "screen" ]]; then
83   PR_STITLE=$'%{\ekzsh\e\\%}'
84 else
85   PR_STITLE=""
86 fi
87
88 # Finally, the prompt.
89 PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
90 $PR_RED$PR_HBAR<\
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}\
93 $PR_RED$PR_HBAR<\
94 $PR_GREEN%l$PR_RED>$PR_HBAR\
95
96 $PR_RED$PR_HBAR<\
97 %(?..$PR_LIGHT_RED%?$PR_BLUE:)\
98 $PR_LIGHT_BLUE%(!.$PR_RED.$PR_WHITE)%#$PR_RED>$PR_HBAR\
99 $PR_NO_COLOUR '