48 lines
1023 B
Bash
48 lines
1023 B
Bash
# LEFT
|
|
# dir vcs command_execution_time status
|
|
# RIGHT
|
|
# background_jobs virtualenv kubecontext
|
|
|
|
autoload -Uz vcs_info
|
|
|
|
zstyle ':vcs_info:*' enable git
|
|
zstyle ':vcs_info:*' check-for-changes true
|
|
zstyle ':vcs_info:git*' formats '%b (%a) %m%u%c'
|
|
|
|
function preexec() {
|
|
_timer_start="$SECONDS"
|
|
}
|
|
|
|
function _get_time() {
|
|
local d="$((SECONDS - _timer_start))"
|
|
local text
|
|
|
|
text="$((d % 60))s"
|
|
if [ "$d" -gt 60 ]; then
|
|
text="$((d % 60))m$text"
|
|
(( d /= 60 ))
|
|
fi
|
|
if [ "$d" -gt 60 ]; then
|
|
text="${d}h$text"
|
|
fi
|
|
echo "$text"
|
|
}
|
|
|
|
function precmd() {
|
|
local err
|
|
|
|
IFS='|' err="${pipestatus[*]}"
|
|
timer="$((SECONDS - _timer_start))"
|
|
|
|
vcs_info
|
|
|
|
PROMPT='%~ '
|
|
[ -n "$vcs_info_msg_0_" ] && PROMPT="$PROMPT$vcs_info_msg_0_ "
|
|
[ "$timer" -ge 2 ] && PROMPT="$PROMPT$(_get_time) "
|
|
[ "$err" != 0 ] && PROMPT="$PROMPT$err "
|
|
|
|
RPROMPT='%(1j.%j.)'
|
|
false && RPROMPT="$RPROMPT virtualenv"
|
|
false && RPROMPT="$RPROMPT kubecontext"
|
|
}
|