zsh / .oh-my-zsh / custom / themes / custom.zsh-themeon commit [zsh] fix prompt for SSH sessions (108ceb9)
   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{107}"   # 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
  41reset="%{%f%}"
  42
  43FMT_VCS_STATUS="%{$color2%}%b%u%c%{%f%} "
  44
  45zstyle ':vcs_info:*' enable git
  46zstyle ':vcs_info:*' check-for-changes true
  47zstyle ':vcs_info:*' unstagedstr    "%{%f%} %{$color4%}●"
  48zstyle ':vcs_info:*' stagedstr      "%{%f%} %{$color5%}✚"
  49zstyle ':vcs_info:*' actionformats  "(%{$color5%}%a%{%f%})${FMT_VCS_STATUS}"
  50zstyle ':vcs_info:*' formats        "${FMT_VCS_STATUS}"
  51zstyle ':vcs_info:*' nvcsformats    ""  # return nothing when no VCS in pwd
  52zstyle ':vcs_info:git*+set-message:*' hooks git-untracked
  53
  54# Check for untracked files
  55+vi-git-untracked() {
  56    if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \
  57            git status --porcelain | grep --max-count=1 '^??' &> /dev/null; then
  58        hook_com[staged]+="%{%f%} %{$color3%}●"
  59    fi
  60}
  61
  62add-zsh-hook precmd vcs_info
  63
  64# Context (user@host)
  65if [[ "$SSH_CLIENT" ]]; then
  66  #context="%{$color0%}%n@%m "
  67  context='%{$color0%}%n@%m%f '
  68fi
  69
  70# Check for suspended processes
  71checkjobs() {
  72  [[ $(jobs -l | wc -l) -gt 0 ]] && echo "%{$color4%}● "
  73}
  74
  75PROMPT='%1(j.'$color4'● .)'$context'%~ ${vcs_info_msg_0_//master/} %(?.'$color0'.'$color3')%(!.#.❯)%f '