autoload -Uz vcs_info colors && colors export VIRTUAL_ENV_DISABLE_PROMPT=1 export GROFF_NO_SGR=1 export LESS_TERMCAP_mb="${fg_bold[red]}" export LESS_TERMCAP_md="${fg_bold[red]}" export LESS_TERMCAP_me="$reset_color" export LESS_TERMCAP_so="${fg_bold[yellow]}${bg[blue]}" export LESS_TERMCAP_se="$reset_color" export LESS_TERMCAP_us="${fg_bold[green]}" export LESS_TERMCAP_ue="$reset_color" . <(dircolors) zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*' zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories zstyle ':vcs_info:*' check-for-changes true zstyle ':vcs_info:*' stagedstr ' %{%F{178}%}+%{%f%b%}' zstyle ':vcs_info:*' unstagedstr ' %{%F{178}%}*%{%f%b%}' zstyle ':vcs_info:git:*' formats '%{%F{76}%}%b%{%f%}%c%u ' zstyle ':vcs_info:git:*' actionformats '%{%F{76}%}%b%{%f%} %{%F{196}%}%a%{%f%}%c%u ' zstyle ':vcs_info:git*+set-message:*' hooks git-untracked function +vi-git-untracked(){ if git status --porcelain | grep '??' &> /dev/null ; then hook_com[unstaged]+=' %{%F{39}%}?%{%f%b%}' fi } function preexec() { PROMPT_timer="$SECONDS" } function _get_time() { local d="$1" local text text="$((d % 60))s" if [ "$d" -gt 60 ]; then (( d /= 60 )) text="$((d % 60))m$text" if [ "$d" -gt 60 ]; then text="${d}h$text" fi fi echo "$text" } function precmd() { IFS='|' local ctx timer err="${pipestatus[*]}" [ -n "$PROMPT_timer" ] && timer="$((SECONDS - PROMPT_timer))" unset -m 'PROMPT_*' ctx="$(kubectx -c)" vcs_info [ -n "$ctx" ] && PROMPT_K8S="%{%F{134}%}$ctx/$(kubens -c)%{%f%b%} " [ "$timer" -ge 2 ] && PROMPT_TIMER="%{%F{101}%}$(_get_time "$timer")%{%f%b%} " [[ "$err" =~ [1-9] ]] && PROMPT_ERR="%{%F{160}%}$err%{%f%b%} " [ -n "$VIRTUAL_ENV" ] && PROMPT_VENV=" %{%F{37}%}${VIRTUAL_ENV:h:t}%{%f%b%}" } setopt PROMPT_SUBST PROMPT='$PROMPT_K8S%{%B%F{32}%}%~%{%f%b%} $vcs_info_msg_0_$PROMPT_TIMER$PROMPT_ERR' RPROMPT='%{%F{71}%}%(1j.%j.)%{%f%b%}$PROMPT_VENV'