-
Notifications
You must be signed in to change notification settings - Fork 719
Git integration via Tig
Johannes Altmanninger edited this page Aug 7, 2022
·
2 revisions
Tig is an ncurses-based interface for Git
Here's how to show git blame
information in Tig:
define-command tig -params .. -docstring "Run tig" %{
terminal env "EDITOR=kak -c %val{session}" tig %arg{@}
}
define-command tig-blame-here -docstring "Run tig blame on the current line" %{
tig -C %sh{git rev-parse --show-toplevel} blame -C "+%val{cursor_line}" -- %sh{
dir="$(git rev-parse --show-toplevel)"
printf %s "${kak_buffile##$dir/}"
}
}
To show the history of the selected lines, try this command (inspired by https://github.com/junegunn/gv.vim):
define-command tig-blame-selection -docstring "Run tig -L on the selected lines" %{
evaluate-commands -draft -save-regs d %{
execute-keys <a-:>
set-register d %sh{git rev-parse --show-toplevel}
tig -C %reg{d} %sh{
anchor=${kak_selection_desc%,*}
anchor_line=${anchor%.*}
cursor=${kak_selection_desc#*,}
cursor_line=${cursor%.*}
d=$kak_reg_d
printf %s "-L$anchor_line,$cursor_line:${kak_buffile##$d/}"
}
}
}
For an alternative approach, see https://github.com/mawww/kakoune/wiki/Integrating-Other-CLI-apps#tig
- Normal mode commands
- Avoid the escape key
- Implementing user mode (Leader key)
- Kakoune explain
- Kakoune TV