[zsh theme] Clean up code

This commit is contained in:
Midgard 2019-06-13 19:42:35 +02:00
parent 7a5304fab1
commit 0c1a5877c1
Signed by untrusted user who does not match committer: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -2,24 +2,26 @@
function my_pwd { function my_pwd {
# ~ for home; keep only the last two directories # ~ for home; keep only the last two directories
echo $(echo "$PWD" | sed -r ' echo "$PWD" | sed -r '
s,^'"$HOME"',~,; t reset; :reset s,^'"$HOME"',~,; t reset; :reset
s|^~/git/my-cool-project/([^/])[^/]+/([^/]+)/|\1/\2/|; t end s|^~/git/my-cool-project/([^/])[^/]+/([^/]+)/|\1/\2/|; t end
s|^.+/([^/]*/[^/]*)$|\1| s|^.+/([^/]*/[^/]*)$|\1|
:end') :end'
} }
function my_retval { function my_retval {
RETVAL=$? RETVAL=$?
if [[ $RETVAL -eq 0 ]]; then if [[ $RETVAL -eq 0 ]]; then
echo "%{$fg[yellow]%}" echo "%{%F{yellow}%}"
else else
echo "%{$fg[red]%}$RETVAL " echo "%{%F{red}%}$RETVAL "
fi fi
} }
PROMPT='$(my_retval)$(my_pwd)$(git_prompt_info)$(git_prompt_status) %{$reset_color%} ' function precmd {
PS1="$(my_retval)$(my_pwd)$(git_prompt_info)$(git_prompt_status) %{%f%} "
}
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[green]%}  " ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[green]%}  "
ZSH_THEME_GIT_PROMPT_SUFFIX="" ZSH_THEME_GIT_PROMPT_SUFFIX=""