1
0
Fork 0
mirror of synced 2024-12-25 23:43:20 -05:00
zimfw/modules/prompt/themes/gitster.zsh-theme

42 lines
965 B
Text
Raw Normal View History

2015-12-18 11:02:56 -05:00
#
# Gitster theme
# https://github.com/shashankmehta/dotfiles/blob/master/thesetup/zsh/.oh-my-zsh/custom/themes/gitster.zsh-theme
#
2016-01-07 08:06:52 -05:00
gst_get_status() {
print "%(?:%F{10}➜ :%F{9}➜ %s)"
}
2015-12-18 11:02:56 -05:00
2016-01-07 08:06:52 -05:00
gst_get_pwd() {
git_root=${PWD}
while [[ ${git_root} != / && ! -e ${git_root}/.git ]]; do
git_root=${git_root:h}
2015-12-18 11:02:56 -05:00
done
2016-01-07 08:06:52 -05:00
if [[ ${git_root} = / ]]; then
2015-12-18 11:02:56 -05:00
unset git_root
2016-01-06 09:41:40 -05:00
prompt_short_dir="$(short_pwd)"
2015-12-18 11:02:56 -05:00
else
parent=${git_root%\/*}
2016-01-07 08:06:52 -05:00
prompt_short_dir=${"$(short_pwd)"#${parent}/}
2015-12-18 11:02:56 -05:00
fi
2016-01-07 08:06:52 -05:00
print ${prompt_short_dir}
2015-12-18 11:02:56 -05:00
}
2016-01-07 08:06:52 -05:00
prompt_gitster_precmd() {
PROMPT='$(gst_get_status) %F{white}$(gst_get_pwd) $(git_prompt_info)%f '
}
2016-01-07 08:06:52 -05:00
prompt_gitster_setup() {
ZSH_THEME_GIT_PROMPT_PREFIX="%F{cyan}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%f"
ZSH_THEME_GIT_PROMPT_DIRTY=" %F{yellow}✗%f"
ZSH_THEME_GIT_PROMPT_CLEAN=" %F{green}✓%f"
autoload -Uz add-zsh-hook
add-zsh-hook precmd prompt_gitster_precmd
prompt_opts=(cr subst percent)
}
2015-12-18 11:02:56 -05:00
prompt_gitster_setup "$@"