2013-05-19 20:56:28 +00:00
|
|
|
#
|
|
|
|
# A colorful, friendly, multiline theme with some handy features.
|
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Paul Gideon Dann <pdgiddie@gmail.com>
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
|
|
|
# Features:
|
2013-11-13 10:46:35 +00:00
|
|
|
# - Simple VCS branch, staged, and unstaged indication.
|
2013-05-19 20:56:28 +00:00
|
|
|
# - Prompt character is different in a VCS repository.
|
|
|
|
# - Last command exit status is displayed when non-zero.
|
|
|
|
#
|
|
|
|
# Screenshots:
|
|
|
|
# http://i.imgur.com/rCo3S.png
|
|
|
|
#
|
|
|
|
|
2013-11-13 10:46:35 +00:00
|
|
|
function +vi-set_novcs_prompt_symbol {
|
|
|
|
_prompt_giddie_symbol=')'
|
|
|
|
}
|
|
|
|
|
|
|
|
function +vi-set_vcs_prompt_symbol {
|
|
|
|
_prompt_giddie_symbol='±'
|
|
|
|
}
|
|
|
|
|
|
|
|
function +vi-git_precmd {
|
|
|
|
# Check for untracked files, since vcs_info does not.
|
2013-05-19 20:56:28 +00:00
|
|
|
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
|
2013-11-13 10:46:35 +00:00
|
|
|
hook_com[unstaged]+='%F{green}?%f'
|
2013-05-19 20:56:28 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function prompt_giddie_precmd {
|
|
|
|
# Replace '/home/<user>' with '~'.
|
|
|
|
_prompt_giddie_pwd="${PWD/#$HOME/~}"
|
2013-11-13 10:46:35 +00:00
|
|
|
vcs_info
|
2013-05-19 20:56:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function prompt_giddie_setup {
|
|
|
|
setopt LOCAL_OPTIONS
|
|
|
|
unsetopt XTRACE KSH_ARRAYS
|
2017-08-10 18:23:26 +00:00
|
|
|
prompt_opts=(cr percent sp subst)
|
2013-05-19 20:56:28 +00:00
|
|
|
|
|
|
|
# Load required functions.
|
|
|
|
autoload -Uz vcs_info
|
|
|
|
autoload -Uz add-zsh-hook
|
|
|
|
|
|
|
|
# Add hook to set up prompt parameters before each command.
|
|
|
|
add-zsh-hook precmd prompt_giddie_precmd
|
|
|
|
|
|
|
|
# Set editor-info parameters.
|
|
|
|
zstyle ':prezto:module:editor:info:completing' format '%F{green}...%f'
|
2013-11-13 10:46:35 +00:00
|
|
|
zstyle ':prezto:module:editor:info:keymap:alternate' format '%F{yellow}--- COMMAND ---%f'
|
2013-05-19 20:56:28 +00:00
|
|
|
|
|
|
|
# Set vcs_info parameters.
|
|
|
|
zstyle ':vcs_info:*' check-for-changes true
|
|
|
|
zstyle ':vcs_info:*' formats ' on %F{magenta}%b%f%c%u'
|
|
|
|
zstyle ':vcs_info:*' actionformats ' on %F{magenta}%b%f%c%u %F{yellow}(%a)%f'
|
|
|
|
zstyle ':vcs_info:*' stagedstr '%F{green}+%f'
|
|
|
|
zstyle ':vcs_info:*' unstagedstr '%F{green}!%f'
|
2013-11-13 10:46:35 +00:00
|
|
|
|
|
|
|
# Set vcs_info hooks.
|
|
|
|
# NOTE: Prior to Zsh v4.3.12, there are no static hooks, no vcs_info_hookadd
|
|
|
|
# function, and no 'no-vcs' hook.
|
|
|
|
zstyle ':vcs_info:*+start-up:*' hooks set_novcs_prompt_symbol
|
|
|
|
zstyle ':vcs_info:git*+set-message:*' hooks set_vcs_prompt_symbol git_precmd
|
|
|
|
zstyle ':vcs_info:*+set-message:*' hooks set_vcs_prompt_symbol
|
2013-05-19 20:56:28 +00:00
|
|
|
|
|
|
|
# Define prompts.
|
|
|
|
PROMPT='%(?..%F{red}%B-> [%?]%b%f
|
|
|
|
)%F{magenta}%n%f@%F{yellow}%m%f|%F{green}${_prompt_giddie_pwd}%f${vcs_info_msg_0_}
|
|
|
|
%F{blue}${_prompt_giddie_symbol}%f '
|
2013-11-13 10:46:35 +00:00
|
|
|
RPROMPT='${editor_info[keymap]}'
|
2013-05-19 20:56:28 +00:00
|
|
|
SPROMPT='zsh: correct %F{magenta}%R%f to %F{green}%r%f [nyae]? '
|
|
|
|
}
|
|
|
|
|
|
|
|
prompt_giddie_setup "$@"
|