4
4
# pure: https://github.com/sindresorhus/pure
5
5
# mnml: https://github.com/subnixr/minimal
6
6
7
- typeset -gA GEOMETRY; GEOMETRY[ROOT]=${0: A: h}
7
+ builtin typeset -gA GEOMETRY; GEOMETRY[ROOT]=${0: A: h}
8
8
9
9
(( $+ GEOMETRY_PROMPT)) || GEOMETRY_PROMPT=(geometry_echo geometry_status geometry_path)
10
10
(( $+ GEOMETRY_RPROMPT)) || GEOMETRY_RPROMPT=(geometry_exec_time geometry_git geometry_hg geometry_jj geometry_echo)
@@ -13,7 +13,7 @@ typeset -gA GEOMETRY; GEOMETRY[ROOT]=${0:A:h}
13
13
(( $+ GEOMETRY_CMDTITLE)) || GEOMETRY_CMDTITLE=(geometry_cmd geometry_hostname)
14
14
(( $+ GEOMETRY_PATH_TRUNCATE)) || GEOMETRY_PATH_TRUNCATE=3
15
15
16
- autoload -U add-zsh-hook
16
+ builtin autoload -U add-zsh-hook
17
17
18
18
function {
19
19
local fun
@@ -40,9 +40,9 @@ for fun (
40
40
) . " ${GEOMETRY[ROOT]} " /functions/$fun
41
41
}
42
42
43
- (( $+ functions[ansi] )) || ansi () { (( $# - 2 )) || echo -n " %F{ $1 } $2 %f " ; }
44
- (( $+ functions[deansi ] )) || deansi () { (( $# - 1 )) || echo -n " $( echo " $1 " | sed s/ $( echo " \033 " ) \\\[\[ 0-9 \]\\\{ 1,2 \\\} m//g ) " ; }
45
- (( $+ functions[geometry_cmd] )) || geometry_cmd () { echo $GEOMETRY_LAST_CMD }
43
+ (( $+ functions[geometry_cmd] )) || geometry_cmd () { builtin echo $GEOMETRY_LAST_CMD ; }
44
+ (( $+ functions[ansi ] )) || ansi () { (( $# - 2 )) || builtin echo -n " %F{ $1 } $2 %f " ; }
45
+ (( $+ functions[deansi] )) || deansi () { (( $# - 1 )) || builtin echo -n " $( echo " $1 " | sed s/ $( builtin echo " \033 " ) \\\[\[ 0-9 \]\\\{ 1,2 \\\} m//g ) " ; }
46
46
47
47
# Takes number of seconds and formats it for humans
48
48
# from https://github.com/sindresorhus/pretty-time-zsh
@@ -68,8 +68,8 @@ geometry::time() {
68
68
# Generate a color based on hostname.
69
69
geometry::hostcolor () {
70
70
if (( ${+GEOMETRY_HOST_COLOR} )) ; then
71
- echo ${GEOMETRY_HOST_COLOR}
72
- return
71
+ builtin echo ${GEOMETRY_HOST_COLOR}
72
+ builtin return
73
73
fi
74
74
75
75
if (( ${+GEOMETRY_HOST_COLORS} )) ; then
@@ -79,22 +79,22 @@ geometry::hostcolor() {
79
79
(( $(echotc Co) == 256 )) && colors+=({17..230})
80
80
fi
81
81
82
- local sum=0; for c in ${(s:: )^HOST} ; do (( sum += $(print - f '% d' "'$c ")) ); done
82
+ local sum=0; for c in ${(s:: )^HOST} ; do (( sum += $(builtin print - f '% d' "'$c ")) ); done
83
83
local index=" $(( $sum % ${# colors} )) "
84
84
85
85
[[ " $index " -eq 0 ]] && index = 1
86
86
87
- echo ${colors[${index}]}
87
+ builtin echo ${colors[${index}]}
88
88
}
89
89
90
90
# set cmd title (while command is running)
91
91
geometry::set_cmdtitle () {
92
92
# Make command title available for optional consumption by geometry_cmd
93
93
GEOMETRY_LAST_CMD=$2
94
- local ansiCmdTitle=$( print -P $( geometry::wrap $PWD $GEOMETRY_CMDTITLE ) )
94
+ local ansiCmdTitle=$( builtin print -P $( geometry::wrap $PWD $GEOMETRY_CMDTITLE ) )
95
95
local cmdTitle=$( deansi " $ansiCmdTitle " )
96
96
97
- echo -ne " \e]1;$cmdTitle \a"
97
+ builtin echo -ne " \e]1;$cmdTitle \a"
98
98
}
99
99
add-zsh-hook preexec geometry::set_cmdtitle
100
100
@@ -103,7 +103,7 @@ geometry::set_title() {
103
103
local ansiTitle=$( print -P $( geometry::wrap $PWD $GEOMETRY_TITLE ) )
104
104
local title=$( deansi " $ansiTitle " )
105
105
106
- echo -ne " \e]1;$title \a"
106
+ builtin echo -ne " \e]1;$title \a"
107
107
}
108
108
add-zsh-hook precmd geometry::set_title
109
109
@@ -112,26 +112,26 @@ geometry::wrap() {
112
112
setopt localoptions noautopushd; builtin cd -q $1
113
113
local -a outputs
114
114
local cmd output
115
- shift
115
+ builtin shift
116
116
for cmd in $@ ; do output=$( $cmd ) ; ( (( $? )) || [[ -z " ${output// } " ]] ) || outputs+=$output ; done
117
117
118
- echo " ${(ej.${GEOMETRY_SEPARATOR:- } .)outputs} "
118
+ builtin echo " ${(ej.${GEOMETRY_SEPARATOR:- } .)outputs} "
119
119
}
120
120
121
121
geometry::rprompt::set () {
122
122
if [[ -z " $2 " || " $2 " == " hup" ]]; then
123
123
read -r -u " $GEOMETRY_ASYNC_FD " RPROMPT
124
- zle reset-prompt
124
+ builtin zle reset-prompt
125
125
exec {1}< & -
126
126
fi
127
- zle -F " $1 "
127
+ builtin zle -F " $1 "
128
128
}
129
129
130
130
geometry::rprompt () {
131
- typeset -g GEOMETRY_ASYNC_FD=
131
+ builtin typeset -g GEOMETRY_ASYNC_FD=
132
132
RPROMPT=
133
133
exec {GEOMETRY_ASYNC_FD}< <( geometry::wrap $PWD $GEOMETRY_RPROMPT )
134
- zle -F " $GEOMETRY_ASYNC_FD " geometry::rprompt::set
134
+ builtin zle -F " $GEOMETRY_ASYNC_FD " geometry::rprompt::set
135
135
}
136
136
137
137
geometry::prompt () {
@@ -144,11 +144,11 @@ add-zsh-hook precmd geometry::prompt
144
144
add-zsh-hook precmd geometry::rprompt
145
145
146
146
geometry::info () { # draw info if no command is given
147
- [[ -n " $BUFFER " ]] && { zle accept-line && return ; }
148
- [[ -z " $GEOMETRY_INFO " ]] && { zle accept-line && return ; }
149
- echo ${(% ):- $(geometry:: wrap $PWD $GEOMETRY_INFO )}
147
+ [[ -n " $BUFFER " ]] && { builtin zle accept-line && builtin return ; }
148
+ [[ -z " $GEOMETRY_INFO " ]] && { builtin zle accept-line && builtin return ; }
149
+ builtin echo ${(% ):- $(geometry:: wrap $PWD $GEOMETRY_INFO )}
150
150
geometry::prompt
151
151
}
152
- zle -N buffer-empty geometry::info
153
- bindkey ' ^M' buffer-empty
152
+ builtin zle -N buffer-empty geometry::info
153
+ builtin bindkey ' ^M' buffer-empty
154
154
ZSH_AUTOSUGGEST_CLEAR_WIDGETS+=buffer-empty
0 commit comments