Commit e9726249 authored by Marc Cornellà's avatar Marc Cornellà
Browse files

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.
parent b4c8b60b
...@@ -50,9 +50,8 @@ zsh_path() { ...@@ -50,9 +50,8 @@ 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"
...@@ -68,12 +67,11 @@ zsh_path() { ...@@ -68,12 +67,11 @@ zsh_path() {
fi fi
(( i++ )) (( i++ ))
else
if [[ $colors -ge 256 ]]; then if [[ $colors -ge 256 ]]; then
print -Pn "%F{065}$c" print -Pn "%F{065}$dir"
else else
print -Pn "%F{blue}$c" print -Pn "%F{blue}$dir"
fi
fi fi
done done
print -Pn "%f" print -Pn "%f"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment