mirror of
https://github.com/dcarrillo/prezto.git
synced 2024-11-01 06:11:12 +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.
70 lines
1.9 KiB
Bash
70 lines
1.9 KiB
Bash
#
|
||
# A single line theme with Git information on the left and Ruby on the right.
|
||
#
|
||
# Authors:
|
||
# Kyle West <kswest@gmail.com>
|
||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||
#
|
||
# Features:
|
||
# - Indicates dirty Git repository.
|
||
# - Indicates the Ruby version.
|
||
# - Indicates vi modes.
|
||
#
|
||
# Screenshots:
|
||
# http://i.imgur.com/dCwhynn.png
|
||
#
|
||
|
||
function prompt_kylewest_precmd {
|
||
setopt LOCAL_OPTIONS
|
||
unsetopt XTRACE KSH_ARRAYS
|
||
|
||
# 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_kylewest_setup {
|
||
setopt LOCAL_OPTIONS
|
||
unsetopt XTRACE KSH_ARRAYS
|
||
prompt_opts=(cr percent sp subst)
|
||
|
||
# Load required functions.
|
||
autoload -Uz add-zsh-hook
|
||
|
||
# Add hook for calling git-info before each command.
|
||
add-zsh-hook precmd prompt_kylewest_precmd
|
||
|
||
# Tell prezto we can manage this prompt
|
||
zstyle ':prezto:module:prompt' managed 'yes'
|
||
|
||
# Set editor-info parameters.
|
||
zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b'
|
||
zstyle ':prezto:module:editor:info:keymap:primary' format "%B%F{green}❯%f%b"
|
||
zstyle ':prezto:module:editor:info:keymap:alternate' format "%B%F{magenta}❮%f%b"
|
||
|
||
# Set git-info parameters.
|
||
zstyle ':prezto:module:git:info' verbose 'no'
|
||
zstyle ':prezto:module:git:info:branch' format '%F{yellow}%b%f'
|
||
zstyle ':prezto:module:git:info:dirty' format '%B%F{red}!%f%b'
|
||
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:keys' format 'prompt' '- %b%D '
|
||
|
||
# Set ruby-info parameters.
|
||
zstyle ':prezto:module:ruby:info:version' format '%F{blue}[%v]%f'
|
||
|
||
# Define prompts.
|
||
PROMPT='%F{cyan}%c%f ${git_info:+${(e)git_info[prompt]}}${editor_info[keymap]} '
|
||
RPROMPT='${ruby_info[version]}'
|
||
}
|
||
|
||
prompt_kylewest_setup "$@"
|
||
# vim: ft=zsh
|