1
0
Fork 0
fzf.kak/rc/modules/VCS/fzf-git.kak

35 lines
1.7 KiB
Text
Raw Normal View History

2018-11-11 10:41:15 +00:00
# ╭─────────────╥─────────────────────────╮
# │ Author: ║ File: │
# │ Andrey Orst ║ fzf-svn.kak │
# ╞═════════════╩═════════════════════════╡
# │ Submodule for Git support for fzf.kak │
# ╞═══════════════════════════════════════╡
# │ GitHub.com/andreyorst/fzf.kak │
# ╰───────────────────────────────────────╯
hook global ModuleLoaded fzf_vcs %§
2018-11-11 10:41:15 +00:00
declare-option -docstring "command to provide list of files in git tree to fzf. Arguments are supported
Supported tools:
<package>: <value>:
Git : ""git""
Default arguments:
2019-09-09 14:59:38 +00:00
'repo_root=$(git rev-parse --show-toplevel); git ls-tree --full-tree --name-only -r HEAD | awk ""{print \""$repo_root/\"" \$0}""'
2018-11-11 10:41:15 +00:00
" \
str fzf_git_command "git"
map global fzf-vcs -docstring "edit file from Git tree" 'g' '<esc>: fzf-git<ret>'
2019-03-17 05:09:34 +00:00
define-command -override -hidden fzf-git %{ evaluate-commands %sh{
2019-09-09 14:59:38 +00:00
2018-11-11 10:41:15 +00:00
case $kak_opt_fzf_git_command in
2019-09-09 14:59:38 +00:00
(git) cmd='repo_root=$(git rev-parse --show-toplevel); git ls-tree --full-tree --name-only -r HEAD | awk "{print \"$repo_root/\" \$0}"' ;;
2019-07-07 08:27:37 +00:00
(git*) cmd=$kak_opt_fzf_git_command ;;
2018-11-11 10:41:15 +00:00
esac
2019-05-13 18:34:46 +00:00
[ ! -z "${kak_client_env_TMUX}" ] && additional_flags="--expect $kak_opt_fzf_vertical_map --expect $kak_opt_fzf_horizontal_map"
2019-09-09 14:59:38 +00:00
printf "%s\n" "fzf -kak-cmd %{edit -existing} -items-cmd %{$cmd} -fzf-args %{-m --expect $kak_opt_fzf_window_map $additional_flags}"
2018-11-11 10:41:15 +00:00
}}
2019-05-09 15:12:06 +00:00
§