Skip to content

Commit 95dabba

Browse files
author
Jonathan Dahan
committed
inline root and colors
1 parent 48a14e4 commit 95dabba

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

geometry.zsh

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,17 @@
55
# mnml: https://github.com/subnixr/minimal
66

77
typeset -gA GEOMETRY
8-
GEOMETRY[ROOT]=${0:A:h}
98

109
(($+GEOMETRY_PROMPT)) || GEOMETRY_PROMPT=(geometry_echo geometry_status geometry_path)
1110
(($+GEOMETRY_RPROMPT)) || GEOMETRY_RPROMPT=(geometry_exec_time geometry_git geometry_hg geometry_echo)
1211
(($+GEOMETRY_INFO)) || GEOMETRY_INFO=(geometry_hostname geometry_jobs)
1312

1413
autoload -U add-zsh-hook
1514

16-
function { local fun; for fun ("${GEOMETRY[ROOT]}"/functions/geometry_*.zsh(N.)) . $fun }
15+
function { local fun; for fun ("${0:A:h}"/functions/geometry_*.zsh(N.)) . $fun }
1716

1817
(( $+functions[ansi] )) || ansi() { (($# - 2)) || echo -n "%F{$1}$2%f"; }
1918

20-
: ${GEOMETRY[TIME_COLOR_SHORT]:=green}
21-
: ${GEOMETRY[TIME_COLOR_NEUTRAL]:=default}
22-
: ${GEOMETRY[TIME_COLOR_LONG]:=red}
23-
2419
# Takes number of seconds and formats it for humans
2520
# from https://github.com/sindresorhus/pretty-time-zsh
2621
geometry::time() {
@@ -34,10 +29,10 @@ geometry::time() {
3429
m=$(( seconds / 60 % 60 ))
3530
s=$(( seconds % 60 ))
3631

37-
(( d > 0 )) && human+="${d}d" && color=$GEOMETRY[TIME_COLOR_LONG]
38-
(( h > 0 )) && human+="${h}h" && : ${color:=$GEOMETRY[TIME_COLOR_NEUTRAL]}
32+
(( d > 0 )) && human+="${d}d" && : ${color:=${GEOMETRY_TIME_COLOR_LONG:-red}}
33+
(( h > 0 )) && human+="${h}h" && : ${color:=${GEOMETRY_TIME_COLOR_NEUTRAL:-default}}
3934
(( m > 0 )) && human+="${m}m"
40-
(( s > 0 )) && human+="${s}s" && : ${color:=$GEOMETRY[TIME_COLOR_SHORT]}
35+
(( s > 0 )) && human+="${s}s" && : ${color:=${GEOMETRY_TIME_COLOR_SHORT:-green}}
4136

4237
${2:-false} && ansi $color ${(j: :)human} || ansi $color $human[1]
4338
}

0 commit comments

Comments
 (0)