diff options
| author | Marc Cornellà <marc.cornella@live.com> | 2018-08-20 18:03:41 +0200 | 
|---|---|---|
| committer | Marc Cornellà <marc.cornella@live.com> | 2018-08-20 18:03:41 +0200 | 
| commit | e97262499780caadf5388c3b612100b87da39548 (patch) | |
| tree | 8b5de0303f413c44daa44de0c7d7b458acf9b55b /themes | |
| parent | b4c8b60bb45f00f3cd68000ceda3c96b2ad852ed (diff) | |
| download | zsh-e97262499780caadf5388c3b612100b87da39548.tar.gz zsh-e97262499780caadf5388c3b612100b87da39548.tar.bz2 zsh-e97262499780caadf5388c3b612100b87da39548.zip | |
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.
Diffstat (limited to 'themes')
| -rwxr-xr-x | themes/trapd00r.zsh-theme | 34 | 
1 files changed, 16 insertions, 18 deletions
| diff --git a/themes/trapd00r.zsh-theme b/themes/trapd00r.zsh-theme index 33579e728..7c36487b3 100755 --- a/themes/trapd00r.zsh-theme +++ b/themes/trapd00r.zsh-theme @@ -50,31 +50,29 @@ zsh_path() {      17  '%F{202}'   18  '%F{166}'    ) -  local c i=1 -  for c (${(s::)PWD}); do -    if [[ $c = "/" ]]; then -      if [[ $i -eq 1 ]]; then -        if [[ $colors -ge 256 ]]; then -          print -Pn "%F{065}%B /%b" -        else -          print -Pn "\e[31;1m /" -        fi +  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"        else -        if [[ $colors -ge 256 ]]; then -          print -Pn "${yellow[$i]:-%f} » " -        else -          print -Pn "%F{yellow} > " -        fi +        print -Pn "\e[31;1m /"        fi - -      (( i++ ))      else        if [[ $colors -ge 256 ]]; then -        print -Pn "%F{065}$c" +        print -Pn "${yellow[$i]:-%f} » "        else -        print -Pn "%F{blue}$c" +        print -Pn "%F{yellow} > "        fi      fi + +    (( i++ )) + +    if [[ $colors -ge 256 ]]; then +      print -Pn "%F{065}$dir" +    else +      print -Pn "%F{blue}$dir" +    fi    done    print -Pn "%f"  } | 
