mirror of
https://github.com/dcarrillo/prezto.git
synced 2024-12-22 21:58:00 +00:00
5566a9c792
This is a new variable that will need to be set on all new prompts and is not backwards compatible with custom prompts that are not prezto managed, but use prezto's editor-info functionality. Updated the README.md with additional information for themes.
90 lines
2.2 KiB
Bash
90 lines
2.2 KiB
Bash
#
|
||
# A simple theme from PeepCode.
|
||
# http://peepcode.com/blog/2012/my-command-line-prompt
|
||
#
|
||
# Authors:
|
||
# Geoffrey Grosenbach <boss@topfunky.com>
|
||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||
#
|
||
# Screenshots:
|
||
# http://i.imgur.com/LhgmW.png
|
||
#
|
||
|
||
function prompt_peepcode_precmd {
|
||
# Get Git repository information.
|
||
if (( $+functions[git-info] )); then
|
||
git-info
|
||
fi
|
||
|
||
# Get Ruby information.
|
||
if (( $+functions[ruby-info] )); then
|
||
ruby-info
|
||
fi
|
||
}
|
||
|
||
function prompt_peepcode_setup {
|
||
setopt LOCAL_OPTIONS
|
||
unsetopt XTRACE KSH_ARRAYS
|
||
prompt_opts=(cr percent sp subst)
|
||
|
||
# Load required functions.
|
||
autoload -Uz add-zsh-hook
|
||
autoload -Uz vcs_info
|
||
|
||
# Add a hook for calling info functions before each command.
|
||
add-zsh-hook precmd prompt_peepcode_precmd
|
||
|
||
# Tell prezto we can manage this prompt
|
||
zstyle ':prezto:module:prompt' managed 'yes'
|
||
|
||
# Set git-info parameters.
|
||
zstyle ':prezto:module:git:info' verbose 'no'
|
||
zstyle ':prezto:module:git:info:action' format ' +%s'
|
||
zstyle ':prezto:module:git:info:branch' format ' %F{8}%b%f'
|
||
zstyle ':prezto:module:git:info:commit' format ' %F{white}%.7c%f'
|
||
zstyle ':prezto:module:git:info:indexed' format ' '
|
||
zstyle ':prezto:module:git:info:unindexed' format ' '
|
||
zstyle ':prezto:module:git:info:untracked' format ' '
|
||
zstyle ':prezto:module:git:info:dirty' format ' %F{8}✗%f'
|
||
zstyle ':prezto:module:git:info:keys' format 'rprompt' '%b%c%s%D'
|
||
|
||
# Set ruby-info parameters.
|
||
zstyle ':prezto:module:ruby:info:version' format ' %F{white}%v%f'
|
||
|
||
# Define prompts.
|
||
PROMPT="
|
||
%~
|
||
%(?.%F{green}${1:-☻ }%f.%F{red}${1:-☻ }%f) "
|
||
RPROMPT='${ruby_info[version]}${git_info[rprompt]}'
|
||
|
||
}
|
||
|
||
function prompt_peepcode_help {
|
||
cat <<EOH
|
||
This prompt's last command exit status symbol is customizable:
|
||
|
||
prompt peepcode [<symbol>]
|
||
|
||
If this option is not provided, the symbol defaults to ☻.
|
||
EOH
|
||
}
|
||
|
||
function prompt_peepcode_preview {
|
||
local +h PROMPT='%# '
|
||
local +h RPROMPT=''
|
||
local +h SPROMPT=''
|
||
|
||
if (( $# > 0 )); then
|
||
prompt_preview_theme 'peepcode' "$@"
|
||
else
|
||
prompt_preview_theme 'peepcode'
|
||
print
|
||
prompt_preview_theme 'peepcode' "❯"
|
||
print
|
||
prompt_preview_theme 'peepcode' "$"
|
||
fi
|
||
}
|
||
|
||
prompt_peepcode_setup "$@"
|
||
# vim: ft=zsh
|