2014-03-08 10:51:16 -07:00
|
|
|
|
# trapd00r.zsh-theme
|
2011-05-29 02:55:24 -07:00
|
|
|
|
#
|
2018-08-19 13:43:47 -07:00
|
|
|
|
# This theme needs a terminal supporting 256 colors as well as unicode.
|
2018-08-20 09:15:49 -07:00
|
|
|
|
# In order to avoid external dependencies, it also has a zsh version of
|
2020-08-31 08:38:30 -07:00
|
|
|
|
# the previously used perl script https://github.com/trapd00r/utils/blob/master/zsh_path,
|
2018-08-19 13:43:47 -07:00
|
|
|
|
# which splits up the current path and makes it fancy.
|
2011-05-29 02:55:24 -07:00
|
|
|
|
#
|
|
|
|
|
# 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
|
|
|
|
|
|
2018-08-20 09:15:49 -07:00
|
|
|
|
local c0=$'\e[m'
|
|
|
|
|
local c1=$'\e[38;5;245m'
|
|
|
|
|
local c2=$'\e[38;5;250m'
|
|
|
|
|
local c3=$'\e[38;5;242m'
|
|
|
|
|
local c4=$'\e[38;5;197m'
|
|
|
|
|
local c5=$'\e[38;5;225m'
|
|
|
|
|
local c6=$'\e[38;5;240m'
|
|
|
|
|
local c7=$'\e[38;5;242m'
|
|
|
|
|
local c8=$'\e[38;5;244m'
|
|
|
|
|
local c9=$'\e[38;5;162m'
|
|
|
|
|
local c10=$'\e[1m'
|
|
|
|
|
local c11=$'\e[38;5;208m\e[1m'
|
|
|
|
|
local c12=$'\e[38;5;142m\e[1m'
|
|
|
|
|
local c13=$'\e[38;5;196m\e[1m'
|
2011-05-29 02:55:24 -07:00
|
|
|
|
|
2018-08-20 08:35:02 -07:00
|
|
|
|
|
|
|
|
|
zsh_path() {
|
2018-08-20 08:45:36 -07:00
|
|
|
|
local colors
|
|
|
|
|
colors=$(echoti colors)
|
|
|
|
|
|
2018-08-20 08:35:02 -07:00
|
|
|
|
local -A yellow
|
|
|
|
|
yellow=(
|
|
|
|
|
1 '%F{228}' 2 '%F{222}' 3 '%F{192}' 4 '%F{186}'
|
|
|
|
|
5 '%F{227}' 6 '%F{221}' 7 '%F{191}' 8 '%F{185}'
|
|
|
|
|
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}'
|
|
|
|
|
)
|
|
|
|
|
|
2018-08-20 09:03:41 -07:00
|
|
|
|
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"
|
2018-08-20 08:35:02 -07:00
|
|
|
|
else
|
2018-08-20 09:03:41 -07:00
|
|
|
|
print -Pn "\e[31;1m /"
|
2018-08-20 08:35:02 -07:00
|
|
|
|
fi
|
|
|
|
|
else
|
2018-08-20 08:45:36 -07:00
|
|
|
|
if [[ $colors -ge 256 ]]; then
|
2018-08-20 09:03:41 -07:00
|
|
|
|
print -Pn "${yellow[$i]:-%f} » "
|
2018-08-20 08:35:02 -07:00
|
|
|
|
else
|
2018-08-20 09:03:41 -07:00
|
|
|
|
print -Pn "%F{yellow} > "
|
2018-08-20 08:35:02 -07:00
|
|
|
|
fi
|
|
|
|
|
fi
|
2018-08-20 09:03:41 -07:00
|
|
|
|
|
|
|
|
|
(( i++ ))
|
|
|
|
|
|
|
|
|
|
if [[ $colors -ge 256 ]]; then
|
|
|
|
|
print -Pn "%F{065}$dir"
|
|
|
|
|
else
|
|
|
|
|
print -Pn "%F{blue}$dir"
|
|
|
|
|
fi
|
2018-08-20 08:35:02 -07:00
|
|
|
|
done
|
2018-08-20 08:50:11 -07:00
|
|
|
|
print -Pn "%f"
|
2018-08-19 13:43:47 -07:00
|
|
|
|
}
|
|
|
|
|
|
2011-05-29 02:55:24 -07:00
|
|
|
|
|
2016-12-30 05:34:16 -07:00
|
|
|
|
# We don't want to use the extended colorset in the TTY / VC.
|
2018-08-20 09:15:49 -07:00
|
|
|
|
if [ "$TERM" = linux ]; then
|
|
|
|
|
c1=$'\e[34;1m'
|
|
|
|
|
c2=$'\e[35m'
|
|
|
|
|
c3=$'\e[31m'
|
|
|
|
|
c4=$'\e[31;1m'
|
|
|
|
|
c5=$'\e[32m'
|
|
|
|
|
c6=$'\e[32;1m'
|
|
|
|
|
c7=$'\e[33m'
|
|
|
|
|
c8=$'\e[33;1m'
|
|
|
|
|
c9=$'\e[34m'
|
|
|
|
|
c11=$'\e[35;1m'
|
|
|
|
|
c12=$'\e[36m'
|
|
|
|
|
c13=$'\e[31;1m'
|
2011-05-29 02:55:24 -07:00
|
|
|
|
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
|
2018-08-20 08:35:02 -07:00
|
|
|
|
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
|
2020-08-04 06:55:04 -07:00
|
|
|
|
PROMPT='${dir_status} ${ret_status}%{$reset_color%}
|
2011-05-29 02:55:24 -07:00
|
|
|
|
> '
|
2018-08-20 09:15:49 -07:00
|
|
|
|
# modified, to be committed
|
2011-05-29 02:55:24 -07:00
|
|
|
|
elif [[ $(git diff --cached --name-status 2>/dev/null ) != "" ]]; then
|
2018-08-20 08:35:02 -07:00
|
|
|
|
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
|
2011-05-29 02:55:24 -07:00
|
|
|
|
PROMPT='${vcs_info_msg_0_}%{$30%} %{$bg_bold[red]%}%{$fg_bold[cyan]%}C%{$fg_bold[black]%}OMMIT%{$reset_color%}
|
2020-08-04 06:55:04 -07:00
|
|
|
|
${dir_status}%{$reset_color%}
|
2011-05-29 02:55:24 -07:00
|
|
|
|
> '
|
|
|
|
|
elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then
|
2018-08-20 08:35:02 -07:00
|
|
|
|
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
|
2011-05-29 02:55:24 -07:00
|
|
|
|
PROMPT='${vcs_info_msg_0_}%{$bg_bold[red]%}%{$fg_bold[blue]%}D%{$fg_bold[black]%}IRTY%{$reset_color%}
|
2020-08-04 06:55:04 -07:00
|
|
|
|
${dir_status}%{$reset_color%}
|
2011-05-29 02:55:24 -07:00
|
|
|
|
%{$c13%}>%{$c0%} '
|
|
|
|
|
else
|
2018-08-20 08:35:02 -07:00
|
|
|
|
dir_status="%{$c1%}%n%{$c4%}@%{$c2%}%m%{$c0%}:%{$c3%}%l%{$c6%}->%{$(zsh_path)%} %{$c0%}(%{$c5%}%?%{$c0%})"
|
2011-05-29 02:55:24 -07:00
|
|
|
|
PROMPT='${vcs_info_msg_0_}
|
2020-08-04 06:55:04 -07:00
|
|
|
|
${dir_status}%{$reset_color%}
|
2011-05-29 02:55:24 -07:00
|
|
|
|
> '
|
2018-08-20 09:15:49 -07:00
|
|
|
|
fi
|
2011-05-29 02:55:24 -07:00
|
|
|
|
}
|