Skip to content

Instantly share code, notes, and snippets.

@stinoga
Last active March 22, 2018 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stinoga/7be3a2cf48b9ce524ab7800f1e49d27e to your computer and use it in GitHub Desktop.
Save stinoga/7be3a2cf48b9ce524ab7800f1e49d27e to your computer and use it in GitHub Desktop.
My ZSH Theme

Rob's ZSH Theme

A ZSH theme optimized for people who use:

  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Monaco)

For Mac users, I highly recommend iTerm 2. I used the default colors but this also works well with Solarized Dark. The dots by the purple branch name denote the current git status:

  • Green: added files.
  • Red/Orange: deleted files.
  • Yellow: modified files.
  • Cyan: untracked files.

Example

function prompt_skwp_precmd {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
# Get Git repository information.
if (( $+functions[git-info] )); then
git-info on
git-info
fi
}
function prompt_skwp_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)
autoload -Uz add-zsh-hook
add-zsh-hook precmd prompt_skwp_precmd
# Use extended color pallete if available.
if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
__PROMPT_SKWP_COLORS=(
"%F{cyan}" # turquoise
"%F{166}" # orange
"%F{magenta}" # purple
"%F{yellow}" # yellow
"%F{green}" # green
)
else
__PROMPT_SKWP_COLORS=(
"%F{cyan}"
"%F{yellow}"
"%F{magenta}"
"%F{red}"
"%F{green}"
)
fi
# git
zstyle ':prezto:module:git:info:branch' format "${__PROMPT_SKWP_COLORS[3]}%b%f"
zstyle ':prezto:module:git:info:added' format "${__PROMPT_SKWP_COLORS[5]}●%f"
zstyle ':prezto:module:git:info:deleted' format "${__PROMPT_SKWP_COLORS[2]}●%f"
zstyle ':prezto:module:git:info:modified' format "${__PROMPT_SKWP_COLORS[4]}●%f"
zstyle ':prezto:module:git:info:untracked' format "${__PROMPT_SKWP_COLORS[1]}●%f"
zstyle ':prezto:module:git:info:keys' format 'prompt' '%b%d%a%m%u'
NEWLINE=$'\n'
PROMPT="${__PROMPT_SKWP_COLORS[5]}--( ${__PROMPT_SKWP_COLORS[1]}%n%f${__PROMPT_SKWP_COLORS[4]}@${__PROMPT_SKWP_COLORS[1]}%m%f ${__PROMPT_SKWP_COLORS[5]})--(${__PROMPT_SKWP_COLORS[4]} %~%f ${__PROMPT_SKWP_COLORS[5]})--( "'$git_info[prompt]'"${__PROMPT_SKWP_COLORS[5]} ) -- :) ${NEWLINE}--$ "
}
prompt_skwp_setup "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment