48 lines
1.5 KiB
Text
48 lines
1.5 KiB
Text
declare-user-mode git
|
|
map -docstring "git" global user g ": enter-user-mode git<ret>"
|
|
map -docstring "lazygit kak cwd" global git g ": terminal lazygit<ret>"
|
|
|
|
define-command lazygit-buffer-dir %{
|
|
evaluate-commands %sh{
|
|
ROOT="$(env -C "$(dirname $kak_buffile)" git rev-parse --show-toplevel)"
|
|
printf "terminal lazygit -p %s" "$ROOT"
|
|
}
|
|
}
|
|
map -docstring "lazygit buffer directory" global git G ": lazygit-buffer-dir<ret>"
|
|
|
|
define-command git-blame %{
|
|
info %sh{
|
|
git -C $(dirname $(realpath $kak_buffile)) blame -L $kak_cursor_line,$kak_cursor_line $(realpath $kak_buffile)
|
|
}
|
|
}
|
|
map -docstring "blame" global git b ": git-blame<ret>"
|
|
map -docstring "show diff" global git d ": git show-diff<ret>"
|
|
map -docstring "hide diff" global git D ": git hide-diff<ret>"
|
|
|
|
provide-module git-diff %~
|
|
|
|
define-command -hidden git-show-diff %{
|
|
evaluate-commands %sh{
|
|
if [ $kak_buffile != $kak_bufname ] && git ls-files --error-unmatch "$kak_buffile" > /dev/null 2>&1; then
|
|
echo "git show-diff"
|
|
fi
|
|
}
|
|
}
|
|
hook global WinCreate .* %{
|
|
evaluate-commands %sh{
|
|
if [ $kak_buffile != $kak_bufname ] && git ls-files --error-unmatch "$kak_buffile" > /dev/null 2>&1; then
|
|
echo "hook window BufWritePost .* git-show-diff"
|
|
echo "hook window BufReload .* git-show-diff"
|
|
fi
|
|
}
|
|
}
|
|
|
|
hook global WinCreate .* %{
|
|
evaluate-commands %sh{
|
|
if [ $kak_buffile != $kak_bufname ] && git ls-files --error-unmatch "$kak_buffile" > /dev/null 2>&1; then
|
|
echo "git show-diff"
|
|
fi
|
|
}
|
|
}
|
|
|
|
~
|