add oh-my-zsh theme compatibility git funcs

This commit is contained in:
Matt Hamilton 2015-12-18 09:45:36 -05:00
parent a15476e6c0
commit 3e6785c993
3 changed files with 35 additions and 1 deletions

View File

@ -3,7 +3,10 @@ Git
Provides nice git aliases and functions.
Many thanks to [Sorin Ionescu](https://github.com/sorin-ionescu) for these.
Also provides functions necessary for many prompts.
Many thanks to [Sorin Ionescu](https://github.com/sorin-ionescu) for the excellent aliases.
Aliases
-------
@ -203,6 +206,7 @@ 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.
@ -215,3 +219,7 @@ 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

@ -0,0 +1,8 @@
# 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

@ -0,0 +1,18 @@
# 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=('--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
#unset FLAGS STATUS