-
Notifications
You must be signed in to change notification settings - Fork 0
/
euclid.zsh
83 lines (74 loc) · 1.37 KB
/
euclid.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
typeset -g EUCLID="${0:A:h}"
euclid::elements() {
local element
local -a elements
for element in $@; do
element=$(euclid::element $element)
[[ -n $element ]] && elements+=$element
done
echo -n "${(j: :)elements}"
}
euclid::element() {
case $# in
1)
local element
zstyle -s ":euclid:elements" "$1" element
$element
;;
2)
zstyle ":euclid:elements" "$1" "$2"
;;
*)
return 1
;;
esac
}
euclid::optics() {
case $# in
1)
local optics
zstyle -s ":euclid:$1" "optics" optics
echo -n "%F{${optics:-none}}"
;;
2)
zstyle ":euclid:$1*" "optics" "$2"
;;
*)
return 1
;;
esac
}
euclid::data() {
case $# in
1)
local data
zstyle -s ":euclid:$1" "data" data
echo -n "$data"
;;
2)
zstyle ":euclid:$1*" "data" "$2"
;;
*)
return 1
;;
esac
}
euclid::fragment() {
local name=$1
local data
shift
data=$(printf "$(euclid::data "$name")" $@)
if [[ -n $data ]]; then
euclid::optics "$name"
echo -n "$data"
echo -n "%f"
fi
}
function {
autoload -Uz add-zsh-hook
local file
for file ($EUCLID/data/**/* $EUCLID/elements/**/*) source $file
}
setopt prompt_subst
PROMPT='$(euclid::elements "logo" "path")'
RPROMPT='$(euclid::elements "git:ref" "git:tracking" "git:index" "git:stash")'