Show smile in prompt if Git commit hash is lucky

Configuration

setopt re_match_pcre

## show git branch at right prompt                                                                                     
autoload -Uz vcs_info
zstyle ':vcs_info:*' formats '(%b)'
zstyle ':vcs_info:*' actionformats '[%s]-(%b|%a)'
precmd () {
  psvar=()
  LANG=en_US.UTF-8 vcs_info                                                  

  if [[ -n $vcs_info_msg_0_  ]]; then
    local rev=$(git rev-parse HEAD 2>/dev/null)
    if [[ $rev =~ '([0-9])\1{3}' ]]; then
      psvar[1]='😊 '
    fi
    psvar[2]="$vcs_info_msg_0_"
  fi                                                                                                       
}
_DIRPART=%B%{$fg[cyan]%}'[%(5~,%-2~/.../%2~,%~)]'%{$reset_color%}%b                                     
RPROMPT=%B"%1(v|%F{magenta}%1v%f%F{green}%2v%f|)"%b${_DIRPART}

Image

f:id:syohex:20200427224124p:plain

Commit ID is generated by commit_artist

Reference