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.
This commit is contained in:
Marc Cornellà 2018-08-20 18:03:41 +02:00
parent b4c8b60bb4
commit e972624997

View File

@ -50,9 +50,8 @@ zsh_path() {
17 '%F{202}' 18 '%F{166}'
)
local c i=1
for c (${(s::)PWD}); do
if [[ $c = "/" ]]; then
local dir i=1
for dir (${(s:/:)PWD}); do
if [[ $i -eq 1 ]]; then
if [[ $colors -ge 256 ]]; then
print -Pn "%F{065}%B /%b"
@ -68,12 +67,11 @@ zsh_path() {
fi
(( i++ ))
else
if [[ $colors -ge 256 ]]; then
print -Pn "%F{065}$c"
print -Pn "%F{065}$dir"
else
print -Pn "%F{blue}$c"
fi
print -Pn "%F{blue}$dir"
fi
done
print -Pn "%f"