Diff
1diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh
2index 22e7f372fffdb1da78ffd3852130340a5d9aa448..221989502360e4182d14489765578b5ee9ff5491 100644
3--- a/lib/termsupport.zsh
4+++ b/lib/termsupport.zsh
5@@ -4,7 +4,7 @@
6 #Limited support for Apple Terminal (Terminal can't set window or tab separately)
7 function title {
8 [ "$DISABLE_AUTO_TITLE" != "true" ] || return
9- if [[ "$TERM" == screen* ]]; then
10+ if [[ "$TERM" == screen* ]]; then
11 print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
12 elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
13 print -Pn "\e]2;$2:q\a" #set window name
14@@ -16,14 +16,18 @@ ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
15 ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
16
17 #Appears when you have the prompt
18-function precmd {
19+function omz_termsupport_precmd {
20 title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
21 }
22
23 #Appears at the beginning of (and during) of command execution
24-function preexec {
25+function omz_termsupport_preexec {
26 emulate -L zsh
27 setopt extended_glob
28 local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
29 title "$CMD" "%100>...>$2%<<"
30 }
31+
32+autoload -U add-zsh-hook
33+add-zsh-hook precmd omz_termsupport_precmd
34+add-zsh-hook preexec omz_termsupport_preexec
35diff --git a/themes/apple.zsh-theme b/themes/apple.zsh-theme
36index 92f1df941e7c0f027b78df4b86ebeeb7db4b82b3..275341dc67a8d85caafe92d78ab414787f104cdc 100644
37--- a/themes/apple.zsh-theme
38+++ b/themes/apple.zsh-theme
39@@ -2,7 +2,7 @@ function toon {
40 echo -n ""
41 }
42
43-get_git_dirty() {
44+get_git_dirty() {
45 git diff --quiet || echo '*'
46 }
47
48@@ -18,9 +18,12 @@ zstyle ':vcs_info:*' formats \
49 zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
50 zstyle ':vcs_info:*' enable git cvs svn
51
52-precmd () {
53+theme_precmd () {
54 vcs_info
55 }
56
57 setopt prompt_subst
58 PROMPT='%{$fg[magenta]%}$(toon)%{$reset_color%} %~/ %{$reset_color%}${vcs_info_msg_0_}%{$reset_color%}'
59+
60+autoload -U add-zsh-hook
61+add-zsh-hook precmd theme_precmd
62diff --git a/themes/jonathan.zsh-theme b/themes/jonathan.zsh-theme
63index add485279cfcc0df29817e1cabc8b8224e9948af..a170a13d0b435e835244c1cb945dbf07f4474beb 100644
64--- a/themes/jonathan.zsh-theme
65+++ b/themes/jonathan.zsh-theme
66@@ -1,19 +1,19 @@
67-function precmd {
68+function theme_precmd {
69 local TERMWIDTH
70 (( TERMWIDTH = ${COLUMNS} - 1 ))
71
72
73 ###
74 # Truncate the path if it's too long.
75-
76+
77 PR_FILLBAR=""
78 PR_PWDLEN=""
79-
80+
81 local promptsize=${#${(%):---(%n@%m:%l)---()--}}
82 local rubyprompt=`rvm_prompt_info`
83 local rubypromptsize=${#${rubyprompt}}
84 local pwdsize=${#${(%):-%~}}
85-
86+
87 if [[ "$promptsize + $rubypromptsize + $pwdsize" -gt $TERMWIDTH ]]; then
88 ((PR_PWDLEN=$TERMWIDTH - $promptsize))
89 else
90@@ -24,7 +24,7 @@ function precmd {
91
92
93 setopt extended_glob
94-preexec () {
95+theme_preexec () {
96 if [[ "$TERM" == "screen" ]]; then
97 local CMD=${1[(wr)^(*=*|sudo|-*)]}
98 echo -n "\ek$CMD\e\\"
99@@ -69,7 +69,7 @@ setprompt () {
100
101 ###
102 # See if we can use extended characters to look nicer.
103-
104+
105 typeset -A altchar
106 set -A altchar ${(s..)terminfo[acsc]}
107 PR_SET_CHARSET="%{$terminfo[enacs]%}"
108@@ -81,10 +81,10 @@ setprompt () {
109 PR_LRCORNER=${altchar[j]:--}
110 PR_URCORNER=${altchar[k]:--}
111
112-
113+
114 ###
115 # Decide if we need to set titlebar text.
116-
117+
118 case $TERM in
119 xterm*)
120 PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
121@@ -96,8 +96,8 @@ setprompt () {
122 PR_TITLEBAR=''
123 ;;
124 esac
125-
126-
127+
128+
129 ###
130 # Decide whether to set a screen title
131 if [[ "$TERM" == "screen" ]]; then
132@@ -105,8 +105,8 @@ setprompt () {
133 else
134 PR_STITLE=''
135 fi
136-
137-
138+
139+
140 ###
141 # Finally, the prompt.
142
143@@ -135,3 +135,7 @@ $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR '
144 }
145
146 setprompt
147+
148+autoload -U add-zsh-hook
149+add-zsh-hook precmd theme_precmd
150+add-zsh-hook preexec theme_preexec
151diff --git a/themes/kolo.zsh-theme b/themes/kolo.zsh-theme
152index 6e04e1595aa4d0d0dfc96f1961bfb756252ed9f4..e743289c35aff6561f519b4702c5b070df08320a 100644
153--- a/themes/kolo.zsh-theme
154+++ b/themes/kolo.zsh-theme
155@@ -7,7 +7,7 @@ zstyle ':vcs_info:*' unstagedstr '%F{yellow}●'
156 zstyle ':vcs_info:*' check-for-changes true
157 zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{11}%r'
158 zstyle ':vcs_info:*' enable git svn
159-precmd () {
160+theme_precmd () {
161 if [[ -z $(git ls-files --other --exclude-standard 2> /dev/null) ]] {
162 zstyle ':vcs_info:*' formats ' [%b%c%u%B%F{green}]'
163 } else {
164@@ -19,3 +19,6 @@ precmd () {
165
166 setopt prompt_subst
167 PROMPT='%B%F{magenta}%c%B%F{green}${vcs_info_msg_0_}%B%F{magenta} %{$reset_color%}%% '
168+
169+autoload -U add-zsh-hook
170+add-zsh-hook precmd theme_precmd