trapd00r.zsh-theme 3.95 KB
Newer Older
1
# trapd00r.zsh-theme
Magnus Woldrich's avatar
Magnus Woldrich committed
2
#
3
4
5
6
# This theme needs a terminal supporting 256 colors as well as unicode.
# In order to avoid external dependencies, it also embeds a (possibly old)
# copy of the perl script located at https://github.com/trapd00r/utils/blob/master/zsh_path,
# which splits up the current path and makes it fancy.
Magnus Woldrich's avatar
Magnus Woldrich committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#
# By default it spans over two lines like so:
#
# scp1@shiva:pts/9-> /home » scp1 (0)
# >
#
# that's  user@host:pts/-> splitted path (return status)
#
# If the current directory is a git repository, we span 3 lines;
#
# git❨ master ❩ DIRTY
# scp1@shiva:pts/4-> /home » scp1 » dev » utils (0)
# >

autoload -U add-zsh-hook
autoload -Uz vcs_info

local c0=$( printf "\e[m")
local c1=$( printf "\e[38;5;245m")
local c2=$( printf "\e[38;5;250m")
local c3=$( printf "\e[38;5;242m")
local c4=$( printf "\e[38;5;197m")
local c5=$( printf "\e[38;5;225m")
local c6=$( printf "\e[38;5;240m")
local c7=$( printf "\e[38;5;242m")
local c8=$( printf "\e[38;5;244m")
local c9=$( printf "\e[38;5;162m")
local c10=$(printf "\e[1m")
local c11=$(printf "\e[38;5;208m\e[1m")
local c12=$(printf "\e[38;5;142m\e[1m")
local c13=$(printf "\e[38;5;196m\e[1m")

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
local zsh_path_pl=' 

use strict;
use Term::ExtendedColor "fg";

chomp(my $pwd = `pwd`);

my @chars = split//, $pwd;

my $i = 1;

for(@chars) {
  if($_ eq "/") {
    if(defined($ENV{DISPLAY})) {
      if($i == 1) {
        print fg("green28", fg("bold", " /"));
        $i++;
        next;
      }
    }
    else {
      if($i == 1) {
        print "\e[31;1m /\e[0m";
        $i++;
        next;
      }
    }

    if(defined($ENV{DISPLAY})) {
      print fg("yellow$i", " » ");
      $i += 6
    }
    else {
      print "\e[33m > \e[0m";
      $i += 6;
    }
  }
  else {
    if(defined($ENV{DISPLAY})) {
      print fg("green28", $_);
    }
    else {
      print "\e[34m$_\e[0m";
    }
  }
}

'
Magnus Woldrich's avatar
Magnus Woldrich committed
87

88
# We don't want to use the extended colorset in the TTY / VC.
Magnus Woldrich's avatar
Magnus Woldrich committed
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
if [ "$TERM" = "linux" ]; then
    c1=$( printf "\e[34;1m")
    c2=$( printf "\e[35m")
    c3=$( printf "\e[31m")
    c4=$( printf "\e[31;1m")
    c5=$( printf "\e[32m")
    c6=$( printf "\e[32;1m")
    c7=$( printf "\e[33m")
    c8=$( printf "\e[33;1m")
    c9=$( printf "\e[34m")

    c11=$(printf "\e[35;1m")
    c12=$(printf "\e[36m")
    c13=$(printf "\e[31;1m")
fi

zstyle ':vcs_info:*' actionformats \
    '%{$c8%}(%f%s)%{$c7%}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '

zstyle ':vcs_info:*' formats \
    "%{$c8%}%s%%{$c7%}❨ %{$c9%}%{$c11%}%b%{$c7%} ❩%{$reset_color%}%f "

zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r'
zstyle ':vcs_info:*' enable git

add-zsh-hook precmd prompt_jnrowe_precmd

prompt_jnrowe_precmd () {
  vcs_info
  if [ "${vcs_info_msg_0_}" = "" ]; then
119
    dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(echo $zsh_path_pl | perl)%} %{$c0%}(%{$c5%}%?%{$c0%})"
Magnus Woldrich's avatar
Magnus Woldrich committed
120
121
122
    PROMPT='%{$fg_bold[green]%}%p%{$reset_color%}${vcs_info_msg_0_}${dir_status} ${ret_status}%{$reset_color%}
> '

123
# modified, to be committed
Magnus Woldrich's avatar
Magnus Woldrich committed
124
  elif [[ $(git diff --cached --name-status 2>/dev/null ) != "" ]]; then
125
    dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(echo $zsh_path_pl | perl)%} %{$c0%}(%{$c5%}%?%{$c0%})"
Magnus Woldrich's avatar
Magnus Woldrich committed
126
127
128
129
130
    PROMPT='${vcs_info_msg_0_}%{$30%} %{$bg_bold[red]%}%{$fg_bold[cyan]%}C%{$fg_bold[black]%}OMMIT%{$reset_color%}
%{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%}
> '

  elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then
131
    dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(echo $zsh_path_pl | perl)%} %{$c0%}(%{$c5%}%?%{$c0%})"
Magnus Woldrich's avatar
Magnus Woldrich committed
132
133
134
135
    PROMPT='${vcs_info_msg_0_}%{$bg_bold[red]%}%{$fg_bold[blue]%}D%{$fg_bold[black]%}IRTY%{$reset_color%}
%{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%}
%{$c13%}>%{$c0%} '
  else
136
    dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(echo $zsh_path_pl | perl)%} %{$c0%}(%{$c5%}%?%{$c0%})"
Magnus Woldrich's avatar
Magnus Woldrich committed
137
    PROMPT='${vcs_info_msg_0_}
138
%{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%}
Magnus Woldrich's avatar
Magnus Woldrich committed
139
140
141
142
> '
fi
}

143

Magnus Woldrich's avatar
Magnus Woldrich committed
144
#  vim: set ft=zsh sw=2 et tw=0: