Get number of lines changed for Git

This commit is contained in:
Benjamin Chrétien 2013-07-06 19:12:21 +09:00 committed by Gaetan Semet
commit c638f9d7fd

View file

@ -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"
}
# 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
parse_git_dirty() {