1
0
Fork 0
mirror of synced 2024-11-26 17:25:35 -05:00

Remove git_prompt_info and parse_git_dirty

as they were only being used by gitster prompt theme and kept for
Oh-My-Zsh compatibility. The newly introduced git-info module (inspired
by the git-info Prezto function) provides a more powerful
implementation than the Oh-My-Zsh inspired git_prompt_info.

Updated gitster to use the git-info module.

Closes #124
This commit is contained in:
Eric Nielsen 2017-01-16 14:02:06 -05:00 committed by Matt Hamilton
parent 9f4c21cee8
commit c1b02c06d0
4 changed files with 19 additions and 43 deletions

View file

@ -208,7 +208,6 @@ You can temporarily bypass an alias by prefixing it with a backward slash:
Functions
---------
General:
- `git-branch-current` displays the current branch.
- `git-commit-lost` lists lost commits.
- `git-dir` displays the path to the Git directory.
@ -221,7 +220,3 @@ Functions
- `git-stash-recover` recovers given dropped stashed states.
- `git-submodule-move` moves a submodule.
- `git-submodule-remove` removes a submodule.
Prompt:
- `git_prompt_info` provides git information to oh-my-zsh sourced prompts.
- `parse-git-dirty` needed for `git-prompt-info` to check if repo is dirty.

View file

@ -1,8 +0,0 @@
# slightly modified git_prompt_info from oh-my-zsh for theme compatibility
local ref
if [[ ${zgit_hide_prompt} != 'true' ]]; then
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0
print "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref#refs/heads/}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
fi

View file

@ -1,17 +0,0 @@
# slightly modified parse_git_dirty from oh-my-zsh for theme compatibility
# not supporting git < 1.7.2; upgrade your shit
local STATUS=''
local FLAGS
FLAGS=('--porcelain' '--ignore-submodules=dirty')
if [[ ${zgit_hide_prompt} != 'true' ]]; then
if [[ "${zgit_disable_untracked_dirty}" == "true" ]]; then
FLAGS+='--untracked-files=no'
fi
STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1)
fi
if [[ -n ${STATUS} ]]; then
print ${ZSH_THEME_GIT_PROMPT_DIRTY}
else
print ${ZSH_THEME_GIT_PROMPT_CLEAN}
fi

View file

@ -3,31 +3,37 @@
# https://github.com/shashankmehta/dotfiles/blob/master/thesetup/zsh/.oh-my-zsh/custom/themes/gitster.zsh-theme
#
gst_get_status() {
print "%(?:%F{10}➜ :%F{9}➜ %s)"
prompt_gitster_get_status() {
print '%(?:%F{green}➜:%F{red}➜) '
}
gst_get_pwd() {
prompt_short_dir="$(short_pwd)"
git_root="$(command git rev-parse --show-toplevel 2> /dev/null)" && \
prompt_short_dir="${prompt_short_dir#${$(short_pwd $git_root):h}/}"
prompt_gitster_get_pwd() {
prompt_short_dir=$(short_pwd)
git_root=$(command git rev-parse --show-toplevel 2> /dev/null) && prompt_short_dir=${prompt_short_dir#${$(short_pwd $git_root):h}/}
print ${prompt_short_dir}
}
prompt_gitster_precmd() {
PROMPT='$(gst_get_status) %F{white}$(gst_get_pwd) $(git_prompt_info)%f '
[[ ${+functions[git-info]} ]] && git-info
}
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 colors && colors
autoload -Uz add-zsh-hook
prompt_opts=(cr percent subst)
add-zsh-hook precmd prompt_gitster_precmd
prompt_opts=(cr subst percent)
zstyle ':zim:git-info:branch' format '%b'
zstyle ':zim:git-info:commit' format '%c'
zstyle ':zim:git-info:clean' format '%F{green}✓'
zstyle ':zim:git-info:dirty' format '%F{yellow}✗'
zstyle ':zim:git-info:keys' format \
'prompt' ' %F{cyan}%b%c %C%D'
PROMPT='$(prompt_gitster_get_status)%F{white}$(prompt_gitster_get_pwd)${(e)git_info[prompt]}%f '
RPROMPT=''
}
prompt_gitster_setup "$@"