From dbbe455eb1ccc9985c3c4965d0f96859242d9d88 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 29 Mar 2013 19:37:35 +0100 Subject: [PATCH] add git-tools.kak, with experimental git diff display as line flags --- src/rc/git-tools.kak | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/rc/git-tools.kak diff --git a/src/rc/git-tools.kak b/src/rc/git-tools.kak new file mode 100644 index 000000000..9ac8c2454 --- /dev/null +++ b/src/rc/git-tools.kak @@ -0,0 +1,25 @@ +decl line-flag-list git_diff_flags + +def git-diff-update-buffer %{ %sh{ + added_lines="" + removed_lines="" + git diff -U0 $kak_bufname | { + line=0 + flags="0:red:." + while read; do + if [[ $REPLY =~ ^---.* ]]; then + continue + elif [[ $REPLY =~ ^@@.-[0-9]+(,[0-9]+)?.\+([0-9]+)(,[0-9]+)?.@@.* ]]; then + line=${BASH_REMATCH[2]} + elif [[ $REPLY =~ ^\+ ]]; then + flags="$flags,$line:green:+" + ((line++)) + elif [[ $REPLY =~ ^\- ]]; then + flags="$flags,$line:red:-" + fi + done + echo "setb git_diff_flags '$flags'" + } +}} + +def git-diff-show %{ addhl flag_lines black git_diff_flags; git-diff-update-buffer }