This repository has been archived on 2022-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
prezto/modules/prompt/functions/prompt_steeef_setup

95 lines
2.7 KiB
Plaintext
Raw Permalink Normal View History

#
2012-08-06 16:43:34 -04:00
# A theme based on Steve Losh's Extravagant Prompt with vcs_info integration.
2012-01-31 23:37:51 -05:00
#
# Authors:
# Steve Losh <steve@stevelosh.com>
# Bart Trojanowski <bart@jukie.net>
# Brian Carper <brian@carper.ca>
# steeef <steeef@gmail.com>
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
2012-08-06 16:53:03 -04:00
# Screenshots:
# http://i.imgur.com/HyRvv.png
#
function prompt_steeef_precmd {
2012-08-06 16:43:34 -04:00
# Check for untracked files or updated submodules since vcs_info does not.
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
2012-08-06 16:43:34 -04:00
branch_format="(${_prompt_steeef_colors[1]}%b%f%u%c${_prompt_steeef_colors[4]}●%f)"
else
2012-08-06 16:43:34 -04:00
branch_format="(${_prompt_steeef_colors[1]}%b%f%u%c)"
fi
2012-08-06 16:43:34 -04:00
zstyle ':vcs_info:*:prompt:*' formats "${branch_format}"
vcs_info 'prompt'
if (( $+functions[python-info] )); then
python-info
fi
}
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
# Use extended color pallete if available.
if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
_prompt_steeef_colors=(
2012-08-06 16:43:34 -04:00
"%F{81}" # Turquoise
"%F{166}" # Orange
"%F{135}" # Purple
"%F{161}" # Hotpink
"%F{118}" # Limegreen
)
else
_prompt_steeef_colors=(
"%F{cyan}"
"%F{yellow}"
"%F{magenta}"
"%F{red}"
"%F{green}"
)
fi
# Formats:
2012-08-06 16:43:34 -04:00
# %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"
2012-08-06 16:43:34 -04:00
# 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.
2012-10-01 22:02:47 -04:00
zstyle ':prezto:module:python:info:virtualenv' format '(%v)'
2012-08-06 16:43:34 -04:00
# Define prompts.
PROMPT="
${_prompt_steeef_colors[3]}%n%f at ${_prompt_steeef_colors[2]}%m%f in ${_prompt_steeef_colors[5]}%~%f "'${vcs_info_msg_0_}'"
"'$python_info[virtualenv]'"$ "
2012-09-10 13:23:34 -04:00
RPROMPT=''
}
prompt_steeef_setup "$@"