mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-22 04:11:58 +00:00
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:
parent
b4c8b60bb4
commit
e972624997
1 changed files with 16 additions and 18 deletions
|
@ -50,31 +50,29 @@ zsh_path() {
|
||||||
17 '%F{202}' 18 '%F{166}'
|
17 '%F{202}' 18 '%F{166}'
|
||||||
)
|
)
|
||||||
|
|
||||||
local c i=1
|
local dir i=1
|
||||||
for c (${(s::)PWD}); do
|
for dir (${(s:/:)PWD}); do
|
||||||
if [[ $c = "/" ]]; then
|
if [[ $i -eq 1 ]]; then
|
||||||
if [[ $i -eq 1 ]]; then
|
if [[ $colors -ge 256 ]]; then
|
||||||
if [[ $colors -ge 256 ]]; then
|
print -Pn "%F{065}%B /%b"
|
||||||
print -Pn "%F{065}%B /%b"
|
|
||||||
else
|
|
||||||
print -Pn "\e[31;1m /"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
if [[ $colors -ge 256 ]]; then
|
print -Pn "\e[31;1m /"
|
||||||
print -Pn "${yellow[$i]:-%f} » "
|
|
||||||
else
|
|
||||||
print -Pn "%F{yellow} > "
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(( i++ ))
|
|
||||||
else
|
else
|
||||||
if [[ $colors -ge 256 ]]; then
|
if [[ $colors -ge 256 ]]; then
|
||||||
print -Pn "%F{065}$c"
|
print -Pn "${yellow[$i]:-%f} » "
|
||||||
else
|
else
|
||||||
print -Pn "%F{blue}$c"
|
print -Pn "%F{yellow} > "
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
(( i++ ))
|
||||||
|
|
||||||
|
if [[ $colors -ge 256 ]]; then
|
||||||
|
print -Pn "%F{065}$dir"
|
||||||
|
else
|
||||||
|
print -Pn "%F{blue}$dir"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
print -Pn "%f"
|
print -Pn "%f"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue