add git-tools.kak, with experimental git diff display as line flags
This commit is contained in:
parent
f09e24607a
commit
dbbe455eb1
25
src/rc/git-tools.kak
Normal file
25
src/rc/git-tools.kak
Normal file
|
@ -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 }
|
Loading…
Reference in New Issue
Block a user