prezto/modules/prompt/functions/prompt_giddie_setup

60 lines
1.7 KiB
Text
Raw Normal View History

2012-03-13 12:26:02 +00:00
#
# A colourful, friendly, multiline theme with some handy features:
#
# Authors:
# Paul Gideon Dann <pdgiddie@gmail.com>
#
2012-12-21 19:38:55 -05:00
# Features:
# - Simple VCS branch, staged, and unstaged indication.
# - Prompt character is different in a VCS repository.
# - Last command exit status is displayed when non-zero.
#
# Screenshots:
# http://i.imgur.com/rCo3S.png
#
2012-03-13 12:26:02 +00:00
function prompt_giddie_precmd {
# Replace "/home/<user>" with "~"
2012-12-21 19:38:55 -05:00
_prompt_giddie_pwd="${PWD/#$HOME/~}"
2012-03-13 12:26:02 +00:00
# Choose prompt symbol based on whether or not we are in a repository.
2012-12-21 19:38:55 -05:00
if (( $+commands[git] )) && git rev-parse 2> /dev/null; then
_prompt_giddie_symbol='±'
vcs_info
2012-03-13 12:26:02 +00:00
else
2012-12-21 19:38:55 -05:00
_prompt_giddie_symbol=')'
2012-03-13 12:26:02 +00:00
fi
}
function prompt_giddie_setup {
2012-12-21 19:38:55 -05:00
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)
# Load required functions.
2012-03-13 12:26:02 +00:00
autoload -Uz vcs_info
autoload -Uz add-zsh-hook
# Add hook to call our function before each command
2012-12-21 19:38:55 -05:00
add-zsh-hook precmd prompt_giddie_precmd
2012-03-13 12:26:02 +00:00
2012-12-21 19:38:55 -05:00
zstyle ':prezto:module:editor:info:completing' format '%F{green}...%f'
zstyle ':prezto:module:editor:info:keymap:alternate' format '%F{yellow}--- VI-COMMAND ---%f'
2012-03-13 12:26:02 +00:00
zstyle ':vcs_info:*' enable git
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'
2012-12-21 19:38:55 -05: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 '
2012-03-13 12:26:02 +00:00
RPROMPT=
SPROMPT='zsh: correct %F{magenta}%R%f to %F{green}%r%f [nyae]? '
2012-03-13 12:26:02 +00:00
}
prompt_giddie_setup "$@"