Skip to content

Instantly share code, notes, and snippets.

@regadas
Created March 3, 2015 18:13
Show Gist options
  • Save regadas/9e8c34a847f58a1ca7c4 to your computer and use it in GitHub Desktop.
Save regadas/9e8c34a847f58a1ca7c4 to your computer and use it in GitHub Desktop.
custom zsh prezto prompt
#
# A simple theme that displays:
# - Python virtual environment.
# - Git branch.
# - Git state.
#
# Authors:
# Filipe Regadas<filiperegadas@gmail.com>
#
# Load dependencies.
pmodload 'helper'
function prompt_regadas_precmd {
unsetopt XTRACE KSH_ARRAYS
# Get Git repository information.
if (( $+functions[git-info] )); then
git-info
fi
# Get Python environment information.
if (( $+functions[python-info] )); then
python-info
fi
# Get Ruby version information.
if (( $+functions[ruby-info] )); then
ruby-info
fi
}
function prompt_regadas_setup {
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(percent subst)
# Add hook for calling git-info before each command.
add-zsh-hook precmd prompt_regadas_precmd
# 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{red}❯%F{yellow}❯%F{green}❯%f%b '
zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format ' %F{red}♺%f '
zstyle ':prezto:module:editor:info:keymap:alternate' format ' %B%F{green}❮%F{yellow}❮%F{red}❮%f%b '
# Set python-info parameters.
zstyle ':prezto:module:python:info:virtualenv' format '%F{yellow}[%v]%f '
# Set ruby-info parameters.
zstyle ':prezto:module:ruby:info:version' format '%F{yellow}[%v]%f '
# Set git-info parameters.
zstyle ':prezto:module:git:info' verbose 'yes'
zstyle ':prezto:module:git:info:branch' format '%F{blue}%b%f'
zstyle ':prezto:module:git:info:dirty' format '%%B%F{red} ±%f%%b'
zstyle ':prezto:module:git:info:keys' format 'prompt' '(%b%D) '
# Define prompts.
PROMPT='$python_info[virtualenv]$ruby_info[version]${git_info:+${(e)git_info[prompt]}}%B%c%b${editor_info[keymap]}'
RPROMPT='${editor_info[overwrite]}${VIM:+" %B%F{green}V%f%b"}'
SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
}
prompt_regadas_setup "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment