zsh / .oh-my-zsh / custom / themes / custom.zsh-themeon commit add new zsh theme (dd64c1a)
   1# zsh theme by Andrew Lorimer <https://lorimer.id.au>
   2
   3# Prompt:
   4# %F => Color codes
   5# %f => Reset color
   6# %~ => Current path
   7# %(x.true.false) => Specifies a ternary expression
   8#   ! => True if the shell is running with root privileges
   9#   ? => True if the exit status of the last command was success
  10#
  11# Git:
  12# %a => Current action (rebase/merge)
  13# %b => Current branch (hide if master)
  14# %c => Staged changes
  15# %u => Unstaged changes
  16#
  17# Terminal:
  18# \n => Newline/Line Feed (LF)
  19
  20setopt PROMPT_SUBST
  21
  22autoload -U add-zsh-hook
  23autoload -Uz vcs_info
  24
  25# Use 256 colours if available
  26if [[ "${terminfo[colors]}" -ge 256 ]]; then
  27  color0="%F{69}"   # blue    context/angle bracket
  28  color1="%F{256}"  # white   pwd text
  29  color2="%F{245}"  # grey    git branch text
  30  color3="%F{167}"  # red     error/untracked
  31  color4="%F{209}"  # orange  warning/unstaged/suspended
  32  color5="%F{107}"  # green   success/staged
  33else    # Fall back to standard ANSI names
  34  color0="%F{blue}"
  35  color1="%F{white}"
  36  color2="%F{cyan}"
  37  color3="%F{red}"
  38  color4="%F{yellow}"
  39  color5="%F{green}"
  40fi
  41
  42FMT_VCS_STATUS="%{$color2%}%b%u%c%{%f%} "
  43
  44zstyle ':vcs_info:*' enable git
  45zstyle ':vcs_info:*' check-for-changes true
  46zstyle ':vcs_info:*' unstagedstr    "%{%f%} %{$color4%}●"
  47zstyle ':vcs_info:*' stagedstr      "%{%f%} %{$color5%}✚"
  48zstyle ':vcs_info:*' actionformats  "(%{$color5%}%a%{%f%})${FMT_VCS_STATUS}"
  49zstyle ':vcs_info:*' formats        "${FMT_VCS_STATUS}"
  50zstyle ':vcs_info:*' nvcsformats    ""  # return nothing when no VCS in pwd
  51zstyle ':vcs_info:git*+set-message:*' hooks git-untracked
  52
  53# Check for untracked files
  54+vi-git-untracked() {
  55    if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \
  56            git status --porcelain | grep --max-count=1 '^??' &> /dev/null; then
  57        hook_com[staged]+="%{%f%} %{$color3%}●"
  58    fi
  59}
  60
  61add-zsh-hook precmd vcs_info
  62
  63# Context (user@host)
  64if [[ "$SSH_CLIENT" ]]; then
  65  context="%{$color0%}%n@%m "
  66fi
  67
  68# Check for suspended processes
  69[[ $(jobs -l | wc -l) -gt 0 ]] && symbols="%{$color4%}● "
  70
  71PROMPT=$'$symbols$context%{%f%}%~%{%f%} ${vcs_info_msg_0_/master/} %(?.%{$color0%}.%{$color3%})%(!.#.❯)%{%f%} '