Skip to content

Instantly share code, notes, and snippets.

@ggrumbley
Created August 29, 2017 13:30
Show Gist options
  • Save ggrumbley/655eb9eb7cf1d7483cfedcc97bf2bffa to your computer and use it in GitHub Desktop.
Save ggrumbley/655eb9eb7cf1d7483cfedcc97bf2bffa to your computer and use it in GitHub Desktop.
My PS1
#
# This is a minimalist ZSH theme for use with Prezto. It uses three colors, supports git users, and looks great in a solarized dark terminal.
#
# Authors:
# Gary Grumbley <[email protected]>
#
# Screenshots:
# https://raw.github.com/stumblingrumblin/theme-gary/master/gary_min.png
#
# Load dependencies.
pmodload 'helper'
function prompt_gary_pwd {
local pwd="${PWD/#$HOME/~}"
if [[ "$pwd" == (#m)[/~] ]]; then
_prompt_gary_pwd="$MATCH"
unset MATCH
else
_prompt_gary_pwd="${${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}//\%/%%}/${${pwd:t}//\%/%%}"
fi
}
function prompt_gary_precmd {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
# Format PWD.
prompt_gary_pwd
# Get Git repository information.
if (( $+functions[git-info] )); then
git-info
fi
# Define prompts.
RPROMPT='%(?:: %F{1}⏎%f)'
}
function prompt_gary_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)
# Load required functions.
autoload -Uz add-zsh-hook
autoload -Uz vcs_info
# Add hook for calling git-info before each command.
add-zsh-hook precmd prompt_gary_precmd
# Set git-info parameters.
zstyle ':prezto:module:git:info' verbose 'yes'
zstyle ':prezto:module:git:info:branch' format '%F{3}[%b'
zstyle ':prezto:module:git:info:dirty' format ' %F{166}✗%f%F{3}]%f'
zstyle ':prezto:module:git:info:clean' format ' %F{6}✔%f%F{3}]%f'
zstyle ':prezto:module:git:info:keys' format \
'prompt' '%b%D%C '
# Define prompts.
PROMPT='%F{166}λ%f %F{6}${_prompt_gary_pwd}%f ${(e)git_info[prompt]}%F{6}❯%F{3}❯%F{166}❯%f '
RPROMPT=''
SPROMPT='zsh: correct %F{1}%R%f to %F{2}%r%f [nyae]? '
}
prompt_gary_setup "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment