aboutsummaryrefslogtreecommitdiff
path: root/templates/.zsh/prompt.zsh
blob: 2e94acb660f75fa918de8fa8dd96fa576223625d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
}

dir_prompt() {
  echo "%F{blue}%~%f"
}

aws_vault_prompt() {
  if [[ "${AWS_VAULT}" != "" ]]
  then
    echo "%F{red}${AWS_VAULT}%f "
  fi
}

export PROMPT='$(aws_vault_prompt)$(dir_prompt)$(git_prompt) '