mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-02-06 02:51:32 +01:00
Get number of lines changed for Git
This commit is contained in:
parent
c1e1dd220f
commit
c638f9d7fd
1 changed files with 9 additions and 0 deletions
|
|
@ -5,6 +5,15 @@ function git_prompt_info() {
|
||||||
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Get the number of lines changed between the index and the working tree
|
||||||
|
function git_changes_info() {
|
||||||
|
changes=$(command git diff --numstat 2>/dev/null) || return
|
||||||
|
if [[ -z "$changes" ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
changes=$(echo $changes | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("+%d/-%d", plus, minus)}')
|
||||||
|
echo "$ZSH_THEME_GIT_CHANGES_PREFIX${changes}$ZSH_THEME_GIT_CHANGES_SUFFIX"
|
||||||
|
}
|
||||||
|
|
||||||
# Checks if working tree is dirty
|
# Checks if working tree is dirty
|
||||||
parse_git_dirty() {
|
parse_git_dirty() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue