aboutsummaryrefslogtreecommitdiff
path: root/templates/.zsh/prompt.zsh
blob: f98a73e33f6de72b521c2c05f206595510f86d47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
autoload -Uz vcs_info
setopt prompt_subst
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr '+'
zstyle ':vcs_info:git:*' unstagedstr '*'
zstyle ':vcs_info:git*' formats " %b%u%c"
zstyle ':vcs_info:git*' actionformats " %b (%a)"

git_prompt() {
  local dirty
  if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
    dirty=$(git status --porcelain 2>/dev/null | wc -l)
    vcs_info
    if [[ "$dirty" -ne "0" ]]; then
      echo -n "%F{yellow}${vcs_info_msg_0_}%f"
    else
      echo -n "%F{green}${vcs_info_msg_0_}%f"
    fi
  fi
}

export PROMPT='%F{blue}%~%f$(git_prompt) '