trapd00r: simplify logic and optimize for loop
This version splits the `$PWD` by the slashes and prints the path
directory by directory, printing the separators as before.
Diff
1diff --git a/themes/trapd00r.zsh-theme b/themes/trapd00r.zsh-theme
2index 33579e728f9374a2004b579e429453ef54d977ac..7c36487b3dc74b394e8851bb88c2bc8270e75024 100755
3--- a/themes/trapd00r.zsh-theme
4+++ b/themes/trapd00r.zsh-theme
5@@ -50,31 +50,29 @@ zsh_path() {
6 17 '%F{202}' 18 '%F{166}'
7 )
8 9- local c i=1
10- for c (${(s::)PWD}); do
11- if [[ $c = "/" ]]; then
12- if [[ $i -eq 1 ]]; then
13- if [[ $colors -ge 256 ]]; then
14- print -Pn "%F{065}%B /%b"
15- else
16- print -Pn "\e[31;1m /"
17- fi
18+ local dir i=1
19+ for dir (${(s:/:)PWD}); do
20+ if [[ $i -eq 1 ]]; then
21+ if [[ $colors -ge 256 ]]; then
22+ print -Pn "%F{065}%B /%b"
23 else
24- if [[ $colors -ge 256 ]]; then
25- print -Pn "${yellow[$i]:-%f} » "
26- else
27- print -Pn "%F{yellow} > "
28- fi
29+ print -Pn "\e[31;1m /"
30 fi
31-
32- (( i++ ))
33 else
34 if [[ $colors -ge 256 ]]; then
35- print -Pn "%F{065}$c"
36+ print -Pn "${yellow[$i]:-%f} » "
37 else
38- print -Pn "%F{blue}$c"
39+ print -Pn "%F{yellow} > "
40 fi
41 fi
42+
43+ (( i++ ))
44+
45+ if [[ $colors -ge 256 ]]; then
46+ print -Pn "%F{065}$dir"
47+ else
48+ print -Pn "%F{blue}$dir"
49+ fi
50 done
51 print -Pn "%f"
52 }