Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Oh My Zsh
Commits
caa93659
Unverified
Commit
caa93659
authored
Aug 25, 2018
by
Marc Cornellà
Committed by
GitHub
Aug 25, 2018
Browse files
Merge pull request #7079 from mcornella/refactor-trapd00r-theme
Refactor trapd00r theme
parents
652356b9
b70a703a
Changes
1
Show whitespace changes
Inline
Side-by-side
themes/trapd00r.zsh-theme
100644 → 100755
View file @
caa93659
# trapd00r.zsh-theme
# trapd00r.zsh-theme
#
#
# This theme needs a terminal supporting 256 colors as well as unicode.
# This theme needs a terminal supporting 256 colors as well as unicode.
# In order to avoid external dependencies, it also
embeds a (possibly old)
# In order to avoid external dependencies, it also
has a zsh version of
#
copy of
the perl script
located
at https://github.com/trapd00r/utils/blob/master/zsh_path,
# the perl script at https://github.com/trapd00r/utils/blob/master/zsh_path,
# which splits up the current path and makes it fancy.
# which splits up the current path and makes it fancy.
#
#
# By default it spans over two lines like so:
# By default it spans over two lines like so:
...
@@ -21,85 +21,77 @@
...
@@ -21,85 +21,77 @@
autoload -U add-zsh-hook
autoload -U add-zsh-hook
autoload -Uz vcs_info
autoload -Uz vcs_info
local
c0
=
$(
printf
"
\e
[m"
)
local c0=$'\e[m'
local
c1
=
$(
printf
"
\e
[38;5;245m"
)
local c1=$'\e[38;5;245m'
local
c2
=
$(
printf
"
\e
[38;5;250m"
)
local c2=$'\e[38;5;250m'
local
c3
=
$(
printf
"
\e
[38;5;242m"
)
local c3=$'\e[38;5;242m'
local
c4
=
$(
printf
"
\e
[38;5;197m"
)
local c4=$'\e[38;5;197m'
local
c5
=
$(
printf
"
\e
[38;5;225m"
)
local c5=$'\e[38;5;225m'
local
c6
=
$(
printf
"
\e
[38;5;240m"
)
local c6=$'\e[38;5;240m'
local
c7
=
$(
printf
"
\e
[38;5;242m"
)
local c7=$'\e[38;5;242m'
local
c8
=
$(
printf
"
\e
[38;5;244m"
)
local c8=$'\e[38;5;244m'
local
c9
=
$(
printf
"
\e
[38;5;162m"
)
local c9=$'\e[38;5;162m'
local
c10
=
$(
printf
"
\e
[1m"
)
local c10=$'\e[1m'
local
c11
=
$(
printf
"
\e
[38;5;208m
\e
[1m"
)
local c11=$'\e[38;5;208m\e[1m'
local
c12
=
$(
printf
"
\e
[38;5;142m
\e
[1m"
)
local c12=$'\e[38;5;142m\e[1m'
local
c13
=
$(
printf
"
\e
[38;5;196m
\e
[1m"
)
local c13=$'\e[38;5;196m\e[1m'
local
zsh_path_pl
=
'
zsh_path() {
use strict;
local colors
use Term::ExtendedColor "fg";
colors=$(echoti colors)
chomp(my $pwd = `pwd`);
local -A yellow
yellow=(
my @chars = split//, $pwd;
1 '%F{228}' 2 '%F{222}' 3 '%F{192}' 4 '%F{186}'
5 '%F{227}' 6 '%F{221}' 7 '%F{191}' 8 '%F{185}'
my $i = 1;
9 '%F{226}' 10 '%F{220}' 11 '%F{190}' 12 '%F{184}'
13 '%F{214}' 14 '%F{178}' 15 '%F{208}' 16 '%F{172}'
17 '%F{202}' 18 '%F{166}'
)
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
print -Pn "\e[31;1m /"
fi
else
if [[ $colors -ge 256 ]]; then
print -Pn "${yellow[$i]:-%f} » "
else
print -Pn "%F{yellow} > "
fi
fi
for(@chars) {
(( i++ ))
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})) {
if [[ $colors -ge 256 ]]; then
print fg("yellow$i", " » ");
print -Pn "%F{065}$dir"
$i += 6
else
}
print -Pn "%F{blue}$dir"
else {
fi
print "\e[33m > \e[0m";
done
$i += 6;
print -Pn "%f"
}
}
else {
if(defined($ENV{DISPLAY})) {
print fg("green28", $_);
}
else {
print "\e[34m$_\e[0m";
}
}
}
}
'
# We don't want to use the extended colorset in the TTY / VC.
# We don't want to use the extended colorset in the TTY / VC.
if
[
"
$TERM
"
=
"linux"
]
;
then
if [ "$TERM" = linux ]; then
c1
=
$(
printf
"
\e
[34;1m"
)
c1=$'\e[34;1m'
c2
=
$(
printf
"
\e
[35m"
)
c2=$'\e[35m'
c3
=
$(
printf
"
\e
[31m"
)
c3=$'\e[31m'
c4
=
$(
printf
"
\e
[31;1m"
)
c4=$'\e[31;1m'
c5
=
$(
printf
"
\e
[32m"
)
c5=$'\e[32m'
c6
=
$(
printf
"
\e
[32;1m"
)
c6=$'\e[32;1m'
c7
=
$(
printf
"
\e
[33m"
)
c7=$'\e[33m'
c8
=
$(
printf
"
\e
[33;1m"
)
c8=$'\e[33;1m'
c9
=
$(
printf
"
\e
[34m"
)
c9=$'\e[34m'
c11=$'\e[35;1m'
c11
=
$(
printf
"
\e
[35;1m"
)
c12=$'\e[36m'
c12
=
$(
printf
"
\e
[36m"
)
c13=$'\e[31;1m'
c13
=
$(
printf
"
\e
[31;1m"
)
fi
fi
zstyle ':vcs_info:*' actionformats \
zstyle ':vcs_info:*' actionformats \
...
@@ -116,29 +108,24 @@ add-zsh-hook precmd prompt_jnrowe_precmd
...
@@ -116,29 +108,24 @@ add-zsh-hook precmd prompt_jnrowe_precmd
prompt_jnrowe_precmd () {
prompt_jnrowe_precmd () {
vcs_info
vcs_info
if [ "${vcs_info_msg_0_}" = "" ]; then
if [ "${vcs_info_msg_0_}" = "" ]; then
dir_status
=
"%{
$c1
%}%n%{
$c4
%}@%{
$c2
%}%m%{
$c0
%}:%{
$c3
%}%l%{
$c6
%}->%{
$(
echo
$
zsh_path
_pl
| perl
)
%} %{
$c0
%}(%{
$c5
%}%?%{
$c0
%})"
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
PROMPT='%{$fg_bold[green]%}%p%{$reset_color%}${vcs_info_msg_0_}${dir_status} ${ret_status}%{$reset_color%}
PROMPT='%{$fg_bold[green]%}%p%{$reset_color%}${vcs_info_msg_0_}${dir_status} ${ret_status}%{$reset_color%}
> '
> '
# modified, to be committed
# modified, to be committed
elif [[ $(git diff --cached --name-status 2>/dev/null ) != "" ]]; then
elif [[ $(git diff --cached --name-status 2>/dev/null ) != "" ]]; then
dir_status
=
"%{
$c1
%}%n%{
$c4
%}@%{
$c2
%}%m%{
$c0
%}:%{
$c3
%}%l%{
$c6
%}->%{
$(
echo
$
zsh_path
_pl
| perl
)
%} %{
$c0
%}(%{
$c5
%}%?%{
$c0
%})"
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
PROMPT='${vcs_info_msg_0_}%{$30%} %{$bg_bold[red]%}%{$fg_bold[cyan]%}C%{$fg_bold[black]%}OMMIT%{$reset_color%}
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%}
%{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%}
> '
> '
elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then
elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then
dir_status
=
"%{
$c1
%}%n%{
$c4
%}@%{
$c2
%}%m%{
$c0
%}:%{
$c3
%}%l%{
$c6
%}->%{
$(
echo
$
zsh_path
_pl
| perl
)
%} %{
$c0
%}(%{
$c5
%}%?%{
$c0
%})"
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
PROMPT='${vcs_info_msg_0_}%{$bg_bold[red]%}%{$fg_bold[blue]%}D%{$fg_bold[black]%}IRTY%{$reset_color%}
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%}
%{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%}
%{$c13%}>%{$c0%} '
%{$c13%}>%{$c0%} '
else
else
dir_status
=
"%{
$c1
%}%n%{
$c4
%}@%{
$c2
%}%m%{
$c0
%}:%{
$c3
%}%l%{
$c6
%}->%{
$(
echo
$
zsh_path
_pl
| perl
)
%} %{
$c0
%}(%{
$c5
%}%?%{
$c0
%})"
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
PROMPT='${vcs_info_msg_0_}
PROMPT='${vcs_info_msg_0_}
%{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%}
%{$fg_bold[green]%}%p%{$reset_color%}${dir_status}%{$reset_color%}
> '
> '
fi
fi
}
}
# vim: set ft=zsh sw=2 et tw=0:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment