I added add-zsh-hook support to the themes that didn't have it already.
This allows the themes to co-exist with plugins and lib/termsupport.
| ... | ... |
@@ -2,7 +2,7 @@ function toon {
|
| 2 | 2 |
echo -n "" |
| 3 | 3 |
} |
| 4 | 4 |
|
| 5 |
-get_git_dirty() {
|
|
| 5 |
+get_git_dirty() {
|
|
| 6 | 6 |
git diff --quiet || echo '*' |
| 7 | 7 |
} |
| 8 | 8 |
|
| ... | ... |
@@ -18,9 +18,12 @@ zstyle ':vcs_info:*' formats \ |
| 18 | 18 |
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
|
| 19 | 19 |
zstyle ':vcs_info:*' enable git cvs svn |
| 20 | 20 |
|
| 21 |
-precmd () {
|
|
| 21 |
+theme_precmd () {
|
|
| 22 | 22 |
vcs_info |
| 23 | 23 |
} |
| 24 | 24 |
|
| 25 | 25 |
setopt prompt_subst |
| 26 | 26 |
PROMPT='%{$fg[magenta]%}$(toon)%{$reset_color%} %~/ %{$reset_color%}${vcs_info_msg_0_}%{$reset_color%}'
|
| 27 |
+ |
|
| 28 |
+autoload -U add-zsh-hook |
|
| 29 |
+add-zsh-hook precmd theme_precmd |
|
| 27 | 30 |
\ No newline at end of file |
| ... | ... |
@@ -1,19 +1,19 @@ |
| 1 |
-function precmd {
|
|
| 1 |
+function theme_precmd {
|
|
| 2 | 2 |
local TERMWIDTH |
| 3 | 3 |
(( TERMWIDTH = ${COLUMNS} - 1 ))
|
| 4 | 4 |
|
| 5 | 5 |
|
| 6 | 6 |
### |
| 7 | 7 |
# Truncate the path if it's too long. |
| 8 |
- |
|
| 8 |
+ |
|
| 9 | 9 |
PR_FILLBAR="" |
| 10 | 10 |
PR_PWDLEN="" |
| 11 |
- |
|
| 11 |
+ |
|
| 12 | 12 |
local promptsize=${#${(%):---(%n@%m:%l)---()--}}
|
| 13 | 13 |
local rubyprompt=`rvm_prompt_info` |
| 14 | 14 |
local rubypromptsize=${#${rubyprompt}}
|
| 15 | 15 |
local pwdsize=${#${(%):-%~}}
|
| 16 |
- |
|
| 16 |
+ |
|
| 17 | 17 |
if [[ "$promptsize + $rubypromptsize + $pwdsize" -gt $TERMWIDTH ]]; then |
| 18 | 18 |
((PR_PWDLEN=$TERMWIDTH - $promptsize)) |
| 19 | 19 |
else |
| ... | ... |
@@ -24,7 +24,7 @@ function precmd {
|
| 24 | 24 |
|
| 25 | 25 |
|
| 26 | 26 |
setopt extended_glob |
| 27 |
-preexec () {
|
|
| 27 |
+theme_preexec () {
|
|
| 28 | 28 |
if [[ "$TERM" == "screen" ]]; then |
| 29 | 29 |
local CMD=${1[(wr)^(*=*|sudo|-*)]}
|
| 30 | 30 |
echo -n "\ek$CMD\e\\" |
| ... | ... |
@@ -69,7 +69,7 @@ setprompt () {
|
| 69 | 69 |
|
| 70 | 70 |
### |
| 71 | 71 |
# See if we can use extended characters to look nicer. |
| 72 |
- |
|
| 72 |
+ |
|
| 73 | 73 |
typeset -A altchar |
| 74 | 74 |
set -A altchar ${(s..)terminfo[acsc]}
|
| 75 | 75 |
PR_SET_CHARSET="%{$terminfo[enacs]%}"
|
| ... | ... |
@@ -81,10 +81,10 @@ setprompt () {
|
| 81 | 81 |
PR_LRCORNER=${altchar[j]:--}
|
| 82 | 82 |
PR_URCORNER=${altchar[k]:--}
|
| 83 | 83 |
|
| 84 |
- |
|
| 84 |
+ |
|
| 85 | 85 |
### |
| 86 | 86 |
# Decide if we need to set titlebar text. |
| 87 |
- |
|
| 87 |
+ |
|
| 88 | 88 |
case $TERM in |
| 89 | 89 |
xterm*) |
| 90 | 90 |
PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
|
| ... | ... |
@@ -96,8 +96,8 @@ setprompt () {
|
| 96 | 96 |
PR_TITLEBAR='' |
| 97 | 97 |
;; |
| 98 | 98 |
esac |
| 99 |
- |
|
| 100 |
- |
|
| 99 |
+ |
|
| 100 |
+ |
|
| 101 | 101 |
### |
| 102 | 102 |
# Decide whether to set a screen title |
| 103 | 103 |
if [[ "$TERM" == "screen" ]]; then |
| ... | ... |
@@ -105,8 +105,8 @@ setprompt () {
|
| 105 | 105 |
else |
| 106 | 106 |
PR_STITLE='' |
| 107 | 107 |
fi |
| 108 |
- |
|
| 109 |
- |
|
| 108 |
+ |
|
| 109 |
+ |
|
| 110 | 110 |
### |
| 111 | 111 |
# Finally, the prompt. |
| 112 | 112 |
|
| ... | ... |
@@ -135,3 +135,7 @@ $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR ' |
| 135 | 135 |
} |
| 136 | 136 |
|
| 137 | 137 |
setprompt |
| 138 |
+ |
|
| 139 |
+autoload -U add-zsh-hook |
|
| 140 |
+add-zsh-hook precmd theme_precmd |
|
| 141 |
+add-zsh-hook preexec theme_preexec |
|
| 138 | 142 |
\ No newline at end of file |
| ... | ... |
@@ -7,7 +7,7 @@ zstyle ':vcs_info:*' unstagedstr '%F{yellow}●'
|
| 7 | 7 |
zstyle ':vcs_info:*' check-for-changes true |
| 8 | 8 |
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{11}%r'
|
| 9 | 9 |
zstyle ':vcs_info:*' enable git svn |
| 10 |
-precmd () {
|
|
| 10 |
+theme_precmd () {
|
|
| 11 | 11 |
if [[ -z $(git ls-files --other --exclude-standard 2> /dev/null) ]] {
|
| 12 | 12 |
zstyle ':vcs_info:*' formats ' [%b%c%u%B%F{green}]'
|
| 13 | 13 |
} else {
|
| ... | ... |
@@ -19,3 +19,6 @@ precmd () {
|
| 19 | 19 |
|
| 20 | 20 |
setopt prompt_subst |
| 21 | 21 |
PROMPT='%B%F{magenta}%c%B%F{green}${vcs_info_msg_0_}%B%F{magenta} %{$reset_color%}%% '
|
| 22 |
+ |
|
| 23 |
+autoload -U add-zsh-hook |
|
| 24 |
+add-zsh-hook precmd theme_precmd |