Last active
November 29, 2016 23:31
-
-
Save ryandao/c523491793ec77e76ff9 to your computer and use it in GitHub Desktop.
My ZSH prompt
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
autoload -U colors && colors | |
autoload -Uz vcs_info | |
autoload -Uz add-zsh-hook | |
function bgcolor { | |
echo "\033[48;5;"$1"m" | |
} | |
function fgcolor { | |
echo "\033[38;5;"$1"m" | |
} | |
function resetcolor { | |
echo "\e[0m" | |
} | |
function format_pwd { | |
local pwd="${PWD/#$HOME/~}" | |
if [[ "$pwd" == (#m)[/~] ]]; then | |
echo "$MATCH" | |
else | |
echo "${${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}//\%/%%}/${${pwd:t}//\%/%%}" | |
fi | |
} | |
function prompt_ryandao_precmd { | |
psvar=() | |
vcs_info | |
[[ -n $vcs_info_msg_0_ ]] && psvar[1]=" [$vcs_info_msg_0_]" | |
} | |
function prompt_ryandao_setup { | |
prompt_opts=(cr percent subst) | |
add-zsh-hook precmd prompt_ryandao_precmd | |
zstyle ':vcs_info:git*' formats "%b" | |
prompt_pwd='$(format_pwd)' | |
PROMPT="%U%{$(fgcolor 255)%}%n%u:%{$(fgcolor 166)%}${prompt_pwd}%{$(fgcolor 10)%}%1v%{$(resetcolor)%}$ " | |
RPROMPT="" | |
} | |
prompt_ryandao_setup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment