mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Merge dc2f28e936 into 9d92987b8a
This commit is contained in:
commit
f62c8742a5
1 changed files with 35 additions and 0 deletions
35
lib/git.zsh
35
lib/git.zsh
|
|
@ -6,6 +6,39 @@ function git_prompt_info() {
|
|||
|
||||
# Checks if working tree is dirty
|
||||
parse_git_dirty() {
|
||||
#do stuff here
|
||||
ver=$(git --version | cut -d " " -f 3)
|
||||
if $(is_legacy_git); then
|
||||
echo $(parse_legacy_git_dirty)
|
||||
else
|
||||
echo $(parse_recent_git_dirty)
|
||||
fi
|
||||
}
|
||||
|
||||
# echos the string 'true' if this git is old enough not to have --ignore-submodules
|
||||
# echos false otherwise
|
||||
is_legacy_git() {
|
||||
checkit() {
|
||||
if [ $1 -gt 1 -o $2 -gt 7 -o $3 -ge 2 ]; then
|
||||
echo false
|
||||
else
|
||||
echo true
|
||||
fi
|
||||
}
|
||||
echo $(checkit $(git --version | cut -d " " -f 3 | tr '.' ' '))
|
||||
}
|
||||
|
||||
# Checks if working tree is dirty when --ignore-submodules is not present
|
||||
parse_legacy_git_dirty() {
|
||||
if [[ -n $(git status --porcelain 2> /dev/null) ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||
else
|
||||
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks if working tree is dirty when git is recent
|
||||
parse_recent_git_dirty() {
|
||||
if [[ -n $(git status -s --ignore-submodules=dirty 2> /dev/null) ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||
else
|
||||
|
|
@ -13,6 +46,8 @@ parse_git_dirty() {
|
|||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
# Checks if there are commits ahead from remote
|
||||
function git_prompt_ahead() {
|
||||
if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue