[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
1 changed files with 7 additions and 5 deletions

View File

@ -2,24 +2,26 @@
function my_pwd {
# ~ for home; keep only the last two directories
echo $(echo "$PWD" | sed -r '
echo "$PWD" | sed -r '
s,^'"$HOME"',~,; t reset; :reset
s|^~/git/my-cool-project/([^/])[^/]+/([^/]+)/|\1/\2/|; t end
s|^.+/([^/]*/[^/]*)$|\1|
:end')
:end'
}
function my_retval {
RETVAL=$?
if [[ $RETVAL -eq 0 ]]; then
echo "%{$fg[yellow]%}"
echo "%{%F{yellow}%}"
else
echo "%{$fg[red]%}$RETVAL "
echo "%{%F{red}%}$RETVAL "
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_SUFFIX=""