Parent directory

jnrowe.zsh-theme

1015 bytes
 1autoload -U add-zsh-hook
 2autoload -Uz vcs_info
 3
 4zstyle ':vcs_info:*' actionformats \
 5       '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f '
 6zstyle ':vcs_info:*' formats '%F{2}%s%F{7}:%F{2}(%F{1}%b%F{2})%f '
 7zstyle ':vcs_info:*' enable git
 8
 9add-zsh-hook precmd prompt_vcs
10
11prompt_vcs () {
12    vcs_info
13
14    if [ "${vcs_info_msg_0_}" = "" ]; then
15        dir_status="%F{2}→%f"
16    elif [[ $(git diff --cached --name-status 2>/dev/null ) != "" ]]; then
17        dir_status="%F{1}▶%f"
18    elif [[ $(git diff --name-status 2>/dev/null ) != "" ]]; then
19        dir_status="%F{3}▶%f"
20    else
21        dir_status="%F{2}▶%f"
22    fi
23}
24
25function {
26    if [[ -n "$SSH_CLIENT" ]]; then
27        PROMPT_HOST=" ($HOST)"
28    else
29        PROMPT_HOST=''
30    fi
31}
32
33local ret_status="%(?:%{$fg_bold[green]%}Ξ:%{$fg_bold[red]%}%S↑%s%?)"
34
35PROMPT='${ret_status}%{$fg[blue]%}${PROMPT_HOST}%{$fg_bold[green]%} %{$fg_bold[yellow]%}%2~ ${vcs_info_msg_0_}${dir_status}%{$reset_color%} '
36
37#  vim: set ft=zsh ts=4 sw=4 et: