Last active
December 31, 2015 18:29
-
-
Save mseri/8026965 to your computer and use it in GitHub Desktop.
My custom zsh theme, to be used with prezto (https://github.com/sorin-ionescu/prezto). It is a modified version of [https://github.com/skwp/dotfiles/blob/master/zsh/prezto-themes/prompt_steeef_simplified_setup](YADR steeef simplified)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# A theme based on Steve Losh's Extravagant Prompt with vcs_info integration. | |
# | |
# Authors: | |
# Marcello Seri <mseri@mseri.me> | |
# Steve Losh <steve@stevelosh.com> | |
# Bart Trojanowski <bart@jukie.net> | |
# Brian Carper <brian@carper.ca> | |
# mseri <mseri@gmail.com> | |
# Sorin Ionescu <sorin.ionescu@gmail.com> | |
# | |
function prompt_mseri_precmd { | |
# Check for untracked files or updated submodules since vcs_info does not. | |
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then | |
branch_format="(${_prompt_mseri_colors[1]}%b%f%u%c${_prompt_mseri_colors[4]}●%f)" | |
else | |
branch_format="(${_prompt_mseri_colors[1]}%b%f%u%c)" | |
fi | |
zstyle ':vcs_info:*:prompt:*' formats "${branch_format}" | |
vcs_info 'prompt' | |
if (( $+functions[python-info] )); then | |
python-info | |
fi | |
# Get ruby information | |
if (( $+functions[ruby-info] )); then | |
ruby-info | |
fi | |
} | |
function prompt_mseri_setup { | |
setopt LOCAL_OPTIONS | |
unsetopt XTRACE KSH_ARRAYS | |
prompt_opts=(cr percent subst) | |
# Load required functions. | |
autoload -Uz add-zsh-hook | |
autoload -Uz vcs_info | |
# Add hook for calling vcs_info before each command. | |
add-zsh-hook precmd prompt_mseri_precmd | |
# Use extended color pallete if available. | |
if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then | |
_prompt_mseri_colors=( | |
"%F{81}" # Turquoise | |
"%F{75}" # Pastel Cyan | |
"%F{215}" # Light Orange | |
"%F{166}" # Orange - not used | |
"%F{119}" # Pastel Limegreen | |
) | |
else | |
_prompt_mseri_colors=( | |
"%F{cyan}" | |
"%F{magenta}" | |
"%F{yellow}" | |
"%F{red}" | |
"%F{green}" | |
) | |
fi | |
# Formats: | |
# %b - branchname | |
# %u - unstagedstr (see below) | |
# %c - stagedstr (see below) | |
# %a - action (e.g. rebase-i) | |
# %R - repository path | |
# %S - path in the repository | |
local branch_format="(${_prompt_mseri_colors[1]}%b%f%u%c)" | |
local action_format="(${_prompt_mseri_colors[5]}%a%f)" | |
local unstaged_format="${_prompt_mseri_colors[2]}●%f" | |
local staged_format="${_prompt_mseri_colors[5]}●%f" | |
# Set vcs_info parameters. | |
zstyle ':vcs_info:*' enable bzr git hg svn | |
zstyle ':vcs_info:*:prompt:*' check-for-changes true | |
zstyle ':vcs_info:*:prompt:*' unstagedstr "${unstaged_format}" | |
zstyle ':vcs_info:*:prompt:*' stagedstr "${staged_format}" | |
zstyle ':vcs_info:*:prompt:*' actionformats "${branch_format}${action_format}" | |
zstyle ':vcs_info:*:prompt:*' formats "${branch_format}" | |
zstyle ':vcs_info:*:prompt:*' nvcsformats "" | |
# Set python-info parameters. | |
zstyle ':prezto:module:python:info:virtualenv' format '(%v)' | |
# Define prompts. | |
PROMPT=" | |
${_prompt_mseri_colors[3]}%n%f@${_prompt_mseri_colors[2]}%m%f ${_prompt_mseri_colors[5]}%~%f "'${vcs_info_msg_0_}'"» " | |
RPROMPT='%F{blue}${ruby_info[version]}' | |
} | |
prompt_mseri_setup "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment