From c638f9d7fd2ad5025bd5a44ceee2f4c0872b6a8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Chr=C3=A9tien?= Date: Sat, 6 Jul 2013 19:12:21 +0900 Subject: [PATCH] Get number of lines changed for Git --- lib/git.zsh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/git.zsh b/lib/git.zsh index 7329011a2..adbc2518c 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -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() {