#
# A theme based on Steve Losh's Extravagant Prompt with vcs_info integration.
# Requires hg-prompt
#
# Authors:
# Steve Losh
# Bart Trojanowski
# Brian Carper
# steeef
# Sorin Ionescu
# haplesshero13
#
# Left prompt is modified version of the Bash prompt by AntiGenX
#
#
# Screenshots:
# TBA
#
function prompt_char {
git branch >/dev/null 2>/dev/null && echo 'λ' && return
hg root >/dev/null 2>/dev/null && echo '☿' && return
echo '$'
}
function hg_prompt_info {
hg prompt "(${_prompt_steeef_colors[1]}{branch}%f${_prompt_steeef_colors[2]}{status|modified|unknown}%f{update})" 2>/dev/null
}
function rvm_info {
if which rvm-prompt &> /dev/null; then
echo "${_prompt_steeef_colors[5]}‹$(rvm-prompt i v g)›"
else
if which rbenv &> /dev/null; then
echo "${_prompt_steeef_colors[5]}‹$(rbenv version | sed -e "s/ (set.*$//")›"
fi
fi
}
function prompt_steeef_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_steeef_colors[1]}%b%f%u%c${_prompt_steeef_colors[4]}●%f)"
else
branch_format="(${_prompt_steeef_colors[1]}%b%f%u%c)"
fi
zstyle ':vcs_info:*:prompt:*' formats "${branch_format}"
vcs_info 'prompt'
}
function prompt_steeef_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_steeef_precmd
_prompt_steeef_colors=(
"%F{cyan}"
"%F{yellow}"
"%F{magenta}"
"%F{red}"
"%F{green}"
)
# 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_steeef_colors[1]}%b%f%u%c)"
local action_format="(${_prompt_steeef_colors[5]}%a%f)"
local unstaged_format="${_prompt_steeef_colors[2]}●%f"
local staged_format="${_prompt_steeef_colors[5]}●%f"
local return_code='%(?..${_prompt_steeef_colors[4]}%? ↵%f)'
# Set vcs_info parameters.
zstyle ':vcs_info:*' enable git
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 ""
# Define prompts.
PROMPT="${_prompt_steeef_colors[3]}%n%f@${_prompt_steeef_colors[2]}%m%f:${_prompt_steeef_colors[1]}%~%f"'$(prompt_char) '
RPROMPT="${return_code} "'${vcs_info_msg_0_}$(hg_prompt_info)$(rvm_info)'
}
prompt_steeef_setup "$@"