@@ -28,7 +28,7 @@ _return_status="%(?..%{$fg[red]%}%? ⚠️%{$reset_color%})"
28
28
29
29
RPROMPT=' %{$(echotc UP 1)%} $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
30
30
31
- function __sobole::current_caret {
31
+ __sobole::current_caret () {
32
32
# This function sets caret color and sign
33
33
# based on theme and privileges.
34
34
if [[ " $USER " == ' root' ]] || [[ " $( id -u " $USER " ) " == 0 ]]; then
@@ -47,7 +47,7 @@ function __sobole::current_caret {
47
47
echo " %{$fg [$CARET_COLOR ]%}$CARET_SIGN %{$reset_color %}"
48
48
}
49
49
50
- function __sobole::current_dir {
50
+ __sobole::current_dir () {
51
51
# Settings up current directory and settings max width for it:
52
52
local max_pwd_length=" ${SOBOLE_MAX_DIR_LEN:- 65} "
53
53
local color
@@ -65,7 +65,7 @@ function __sobole::current_dir {
65
65
fi
66
66
}
67
67
68
- function __sobole::user_info {
68
+ __sobole::user_info () {
69
69
# Shows user in the PROMPT if needed.
70
70
if [[ ! -z " $SOBOLE_DEFAULT_USER " ]] &&
71
71
[[ " $USER " != " $SOBOLE_DEFAULT_USER " ]]; then
@@ -85,7 +85,7 @@ function __sobole::user_info {
85
85
# Disable the standard prompt:
86
86
export VIRTUAL_ENV_DISABLE_PROMPT=1
87
87
88
- function __sobole::current_venv {
88
+ __sobole::current_venv () {
89
89
if [[ ! -z " $VIRTUAL_ENV " ]]; then
90
90
# Show this info only if virtualenv is activated:
91
91
local dir=$( basename " $VIRTUAL_ENV " )
215
215
216
216
_SOBOLE_ADD_LINE_SEPARATOR=' false'
217
217
218
- preexec () {
219
- if [[ " $2 " == ' clear' ]]; then
218
+ __sobole:: preexec () {
219
+ if [[ $# -eq 0 ]] || [[ " $2 " == ' clear' ]]; then
220
220
_SOBOLE_ADD_LINE_SEPARATOR=' false'
221
221
else
222
222
_SOBOLE_ADD_LINE_SEPARATOR=' true'
223
223
fi
224
224
}
225
225
226
- precmd () {
227
- if [[ " $_SOBOLE_ADD_LINE_SEPARATOR " == ' true' ]]; then
226
+ __sobole::precmd () {
227
+ local cmd_result=" $? "
228
+ if [[ " $_SOBOLE_ADD_LINE_SEPARATOR " == ' true' ]] ||
229
+ [[ " $cmd_result " -ne 0 ]]; then
228
230
print
229
231
fi
230
232
}
233
+
234
+ autoload -Uz add-zsh-hook
235
+ add-zsh-hook preexec __sobole::preexec
236
+ add-zsh-hook precmd __sobole::precmd
0 commit comments