1d26e2ab6f0b57ae8599d59e120df2aea1f125f3

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

trapd00r: convert perl script to zsh

Used color encodings from
https://metacpan.org/source/WOLDRICH/Term-ExtendedColor-0.224/lib/Term/ExtendedColor.pm

Diff

This diff is truncated to protect this page.

  1diff --git a/themes/trapd00r.zsh-theme b/themes/trapd00r.zsh-theme
  2old mode 100644
  3new mode 100755
  4index fa8d21898624bb143286b106fcd68ce205fe75bf..2feca08b99717154bda4bff1055295e8a8d544f2
  5--- a/themes/trapd00r.zsh-theme
  6+++ b/themes/trapd00r.zsh-theme
  7@@ -36,54 +36,46 @@ local c11=$(printf "\e[38;5;208m\e[1m")
  8 local c12=$(printf "\e[38;5;142m\e[1m")
  9 local c13=$(printf "\e[38;5;196m\e[1m")
 10 
 11-local zsh_path_pl=' 
 12-
 13-use strict;
 14-use Term::ExtendedColor "fg";
 15-
 16-chomp(my $pwd = `pwd`);
 17-
 18-my @chars = split//, $pwd;
 19-
 20-my $i = 1;
 21-
 22-for(@chars) {
 23-  if($_ eq "/") {
 24-    if(defined($ENV{DISPLAY})) {
 25-      if($i == 1) {
 26-        print fg("green28", fg("bold", " /"));
 27-        $i++;
 28-        next;
 29-      }
 30-    }
 31-    else {
 32-      if($i == 1) {
 33-        print "\e[31;1m /\e[0m";
 34-        $i++;
 35-        next;
 36-      }
 37-    }
 38-
 39-    if(defined($ENV{DISPLAY})) {
 40-      print fg("yellow$i", " » ");
 41-      $i += 6
 42-    }
 43-    else {
 44-      print "\e[33m > \e[0m";
 45-      $i += 6;
 46-    }
 47-  }
 48-  else {
 49-    if(defined($ENV{DISPLAY})) {
 50-      print fg("green28", $_);
 51-    }
 52-    else {
 53-      print "\e[34m$_\e[0m";
 54-    }
 55-  }
 56+
 57+zsh_path() {
 58+  local -A yellow
 59+  yellow=(
 60+    1  '%F{228}'   2  '%F{222}'   3  '%F{192}'   4  '%F{186}'
 61+    5  '%F{227}'   6  '%F{221}'   7  '%F{191}'   8  '%F{185}'
 62+    9  '%F{226}'   10  '%F{220}'   11  '%F{190}'   12  '%F{184}'
 63+    13  '%F{214}'   14  '%F{178}'  15  '%F{208}'   16  '%F{172}'
 64+    17  '%F{202}'   18  '%F{166}'
 65+  )
 66+
 67+  local c i=1
 68+  for c (${(s::)PWD}); do
 69+    if [[ $c = "/" ]]; then
 70+      if [[ $i -eq 1 ]]; then
 71+        if [[ -n "$DISPLAY" ]]; then
 72+          print -Pn '%F{065}%B /%b%f'
 73+        else
 74+          print -Pn '\e[31;1m /%f'
 75+        fi
 76+        (( i++ ))
 77+        continue
 78+      fi
 79+
 80+      if [[ -n "$DISPLAY" ]]; then
 81+        print -Pn "${yellow[$i]:-%f} » %f"
 82+      else
 83+        print -Pn "%F{yellow} > %f"
 84+      fi
 85+      (( i += 6 ))
 86+    else
 87+      if [[ -n "$DISPLAY" ]]; then
 88+        print -Pn "%F{065}$c%f"
 89+      else
 90+        print -Pn "%F{blue}$c%f"
 91+      fi
 92+    fi
 93+  done
 94 }
 95 
 96-'
 97 
 98 # We don't want to use the extended colorset in the TTY / VC.
 99 if [ "$TERM" = "linux" ]; then
100@@ -116,24 +108,24 @@ add-zsh-hook precmd prompt_jnrowe_precmd
101 prompt_jnrowe_precmd () {
102   vcs_info
103   if [ "${vcs_info_msg_0_}" = "" ]; then
104-    dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(echo $zsh_path_pl | perl)%} %{$c0%}(%{$c5%}%?%{$c0%})"
105+    dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
106     PROMPT='%{$fg_bold[green]%}%p%{$reset_color%}${vcs_info_msg_0_}${dir_status} ${ret_status}%{$reset_color%}