Last active
November 16, 2016 19:09
-
-
Save jpts/00fff8a848738f39fc42eca181769f67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Custom prezto prompt | |
# Modified from https://gist.github.com/wikimatze/4c2fbaf8ebe1e8ce0c1f#file-prompt_wikimatze_setup | |
function prompt_jpts_precmd { | |
if (( $+functions[git-info] )); then | |
git-info | |
fi | |
} | |
function prompt_jpts_setup { | |
setopt LOCAL_OPTIONS | |
unsetopt XTRACE KSH_ARRAYS | |
prompt_opts=(cr percent subst) | |
# Load required functions. | |
autoload -Uz add-zsh-hook | |
# Add hook for calling git-info before each command. | |
add-zsh-hook precmd prompt_jpts_precmd | |
# Set appropriate colours | |
if [[ $TERM_PROGRAM = "Apple_Terminal" && $TERM = *"256color" ]]; then | |
_prompt_colors=( | |
"%F{196}" # Red | |
"%F{0}" # Dark grey | |
"%F{242}" # Grey | |
"%F{196}" # Red | |
) | |
elif [[ $TERM = *"256color" || $TERM = *"rxvt"* ]]; then | |
_prompt_colors=( | |
"%F{196}" # Red | |
"%F{255}" # White | |
"%F{242}" # Grey | |
"%F{196}" # Red | |
) | |
else | |
_prompt_colors=( | |
"%F{red}" | |
"%F{white}" | |
"%F{blue}" | |
"%F{red}" | |
) | |
fi | |
if (( $+functions[git-info] )); then | |
# Set git-info parameters. | |
zstyle ':prezto:module:git:info' verbose 'yes' | |
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:stashed' format ' %%B%F{cyan}✭%f%%b' | |
zstyle ':prezto:module:git:info:clean' format ' %F{green}✔%f' | |
zstyle ':prezto:module:git:info:dirty' format ' %F{red}✗%f' | |
zstyle ':prezto:module:git:info:untracked' format ' %%B%F{white}◼%f%%b' | |
zstyle ':prezto:module:git:info:keys' format \ | |
'prompt' ' %F{green}(%f$(coalesce "%b" "%p" "%c")${git_info[rprompt]}%s%F{green})%f' \ | |
'rprompt' '%A%B%S%C%D%U%u' | |
PROMPT="${_prompt_colors[1]}%n%f@${_prompt_colors[2]}%m%f ${_prompt_colors[3]}%2d%f"'${(e)git_info[prompt]}'" ${_prompt_colors[4]}»%f " | |
RPROMPT='' | |
else | |
PROMPT="${_prompt_colors[1]}%n%f@${_prompt_colors[2]}%m%f ${_prompt_colors[3]}%2d%f ${_prompt_colors[4]}»%f " | |
RPROMPT='' | |
fi | |
} | |
prompt_jpts_setup "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment