Skip to content

Instantly share code, notes, and snippets.

@drslump
Last active December 26, 2015 21:09
Show Gist options
  • Select an option

  • Save drslump/7214396 to your computer and use it in GitHub Desktop.

Select an option

Save drslump/7214396 to your computer and use it in GitHub Desktop.
custom prompt for Prezto (.zprezto)
#
# DrSlump custom theme.
#
# Authors:
# Iván -DrSlump- Montes <[email protected]>
#
# Define functions for ZLE that activate on mode change
function zle-line-init zle-keymap-select {
local iterm_vert='\e]50;CursorShape=1\x7'
local iterm_block='\e]50;CursorShape=0\x7'
echo -n "${${KEYMAP/vicmd/$iterm_block}/(main|viins)/$iterm_vert}"
zle reset-prompt
}
# Trigger the mode change callback
#zle -N zle-line-init
#zle -N zle-keymap-select
# pyenv
function prompt_drslump_venv {
setopt promptsubst
local pyenv="${PYENV_VERSION:=$PYENV_LOCAL_VERSION}"
if [[ $pyenv != '' ]]; then
echo "%f%F{blue}py%f:%F{yellow}$pyenv%f"
fi
}
function prompt_drslump_precmd {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
# Get Git information if available
#if (( $+functions[git-info] )); then
# git-info
#fi
# Use a very simple/fast method to obtain teh current branch
branch=`git symbolic-ref --short HEAD 2> /dev/null`
if [[ $branch != '' ]]; then
branch="%F{blue}git%f:%F{green}$branch%f"
fi
}
function prompt_drslump_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)
autoload -Uz add-zsh-hook
add-zsh-hook precmd prompt_drslump_precmd
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:primary:insert' format ''
zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format '%F{red}♺%f'
zstyle ':prezto:module:editor:info:keymap:alternate' format '%B%F{yellow}❯%b%f'
# Set git-info parameters.
#zstyle ':prezto:module:git:info' verbose 'yes'
#zstyle ':prezto:module:git:info:action' format ':%%B%F{yellow}%s%f%%b'
#zstyle ':prezto:module:git:info:added' format ' %%B%F{green}✚%f%%b'
#zstyle ':prezto:module:git:info:ahead' format ' %%B%F{yellow}⬆%f%%b'
#zstyle ':prezto:module:git:info:behind' format ' %%B%F{yellow}⬇%f%%b'
#zstyle ':prezto:module:git:info:branch' format ':%F{green}%b%f'
#zstyle ':prezto:module:git:info:commit' format ':%F{green}%.7c%f'
#zstyle ':prezto:module:git:info:deleted' format ' %%B%F{red}✖%f%%b'
#zstyle ':prezto:module:git:info:modified' format ' %%B%F{blue}✱%f%%b'
#zstyle ':prezto:module:git:info:position' format ':%F{red}%p%f'
#zstyle ':prezto:module:git:info:renamed' format ' %%B%F{magenta}➜%f%%b'
#zstyle ':prezto:module:git:info:stashed' format ' %%B%F{cyan}✭%f%%b'
#zstyle ':prezto:module:git:info:unmerged' format ' %%B%F{yellow}═%f%%b'
#zstyle ':prezto:module:git:info:untracked' format ' %%B%F{white}◼%f%%b'
#zstyle ':prezto:module:git:info:keys' format \
# 'prompt' '' \
# 'rprompt' "%F{blue}git%f$(coalesce '%b' '%c')%s%A%B%S%a%d%m%r%U%u"
# Define prompts.
PROMPT='%F{cyan}%1~%f %(!.%B%F{red}#%f%b.)${editor_info[keymap]} '
#RPROMPT='$(prompt_drslump_venv) ${git_info[rprompt]} ${editor_info[overwrite]}%(?:: %F{red}⏎%f)'
RPROMPT='$(prompt_drslump_venv) ${branch} ${editor_info[overwrite]}%(?:: %F{red}⏎%f)'
SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
}
prompt_drslump_setup "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment