4
4
# pure: https://github.com/sindresorhus/pure
5
5
# mnml: https://github.com/subnixr/minimal
6
6
7
- GEOMETRY_ROOT=${0: A: h}
8
- : ${GEOMETRY_SEPARATOR:= " " }
7
+ typeset -A GEOMETRY
8
+ GEOMETRY[ROOT]=${0: A: h}
9
+ : ${GEOMETRY[SEPARATOR]:= " " }
9
10
10
11
(( $+ GEOMETRY_PROMPT)) || GEOMETRY_PROMPT=(geometry_echo geometry_status geometry_path)
11
12
(( $+ GEOMETRY_RPROMPT)) || GEOMETRY_RPROMPT=(geometry_exec_time geometry_git geometry_hg geometry_echo)
12
13
(( $+ GEOMETRY_INFO)) || GEOMETRY_INFO=(geometry_hostname geometry_jobs)
13
14
14
15
autoload -U add-zsh-hook
15
16
16
- function { local fun; for fun (" ${GEOMETRY_ROOT } " /functions/geometry_* .zsh(N.)) . $fun }
17
+ function { local fun; for fun (" ${GEOMETRY[ROOT] } " /functions/geometry_* .zsh(N.)) . $fun }
17
18
18
19
(( $+ functions[ansi] )) || ansi () { (( $# - 2 )) || echo -n " %F{$1 }$2 %f" ; }
19
20
20
- : ${GEOMETRY_TIME_COLOR_SHORT := green}
21
- : ${GEOMETRY_TIME_COLOR_NEUTRAL := default}
22
- : ${GEOMETRY_TIME_COLOR_LONG := red}
21
+ : ${GEOMETRY[TIME_COLOR_SHORT] := green}
22
+ : ${GEOMETRY[TIME_COLOR_NEUTRAL] := default}
23
+ : ${GEOMETRY[TIME_COLOR_LONG] := red}
23
24
24
25
# Takes number of seconds and formats it for humans
25
26
# from https://github.com/sindresorhus/pretty-time-zsh
@@ -34,10 +35,10 @@ geometry::time() {
34
35
m=$(( seconds / 60 % 60 ))
35
36
s=$(( seconds % 60 ))
36
37
37
- (( d > 0 )) && human+=" ${d} d" && color=$GEOMETRY_TIME_COLOR_LONG
38
- (( h > 0 )) && human+=" ${h} h" && : ${color:= $GEOMETRY_TIME_COLOR_NEUTRAL }
38
+ (( d > 0 )) && human+=" ${d} d" && color=$GEOMETRY [TIME_COLOR_LONG]
39
+ (( h > 0 )) && human+=" ${h} h" && : ${color:= $GEOMETRY [TIME_COLOR_NEUTRAL] }
39
40
(( m > 0 )) && human+=" ${m} m"
40
- (( s > 0 )) && human+=" ${s} s" && : ${color:= $GEOMETRY_TIME_COLOR_SHORT }
41
+ (( s > 0 )) && human+=" ${s} s" && : ${color:= $GEOMETRY [TIME_COLOR_SHORT] }
41
42
42
43
${2:- false} && ansi $color ${(j: : )human} || ansi $color $human [1]
43
44
}
@@ -62,21 +63,21 @@ geometry::wrap() {
62
63
63
64
geometry::rprompt::set () {
64
65
if [[ -z " $2 " || " $2 " == " hup" ]]; then
65
- read -r -u " $PCFD " RPROMPT
66
+ read -r -u " $GEOMETRY_ASYNC_FD " RPROMPT
66
67
zle reset-prompt
67
68
exec {1}< & -
68
69
fi
69
70
zle -F " $1 "
70
71
}
71
72
72
73
geometry::rprompt () {
73
- typeset -g PCFD
74
- exec {PCFD }< <( geometry::wrap $PWD $GEOMETRY_RPROMPT )
75
- zle -F " $PCFD " geometry::rprompt::set
74
+ typeset -g GEOMETRY_ASYNC_FD
75
+ exec {GEOMETRY_ASYNC_FD }< <( geometry::wrap $PWD $GEOMETRY_RPROMPT )
76
+ zle -F " $GEOMETRY_ASYNC_FD " geometry::rprompt::set
76
77
}
77
78
78
79
geometry::prompt () {
79
- GEOMETRY_LAST_STATUS =" $status "
80
+ GEOMETRY[LAST_STATUS] =" $status "
80
81
PROMPT=" $( geometry::wrap $PWD $GEOMETRY_PROMPT ) $GEOMETRY_SEPARATOR "
81
82
geometry::rprompt
82
83
}
0 commit comments