-
Notifications
You must be signed in to change notification settings - Fork 25
Custom Commands
rbong edited this page Jul 3, 2022
·
12 revisions
Put custom commands in an autogroup
in your .vimrc
, like so:
v1
augroup flog
autocmd FileType floggraph nno <buffer> x :<C-U>call flog#run_command('command goes here')<CR>
" etc.
augroup END
v2
augroup flog
autocmd FileType floggraph nno <buffer> x :<C-U>call flog#Exec('command goes here')<CR>
" etc.
augroup END
This will create a fixup commit for the commit under the cursor in normal mode when pressing cf
.
Fixup commits are automatically applied to other commits when running git rebase --autosquash
.
v1
autocmd FileType floggraph nno <buffer> cf :<C-U>call flog#run_command('Git commit -m "fixup! %h"', 0, 1)<CR>
v2
autocmd FileType floggraph nno <buffer> cf :<C-U>call flog#Exec('Git commit -m "fixup! %h"', 0, 1)<CR>
This will reset to the selected commit using --mixed
with cv
, and using --hard
with cV
.
v1
autocmd FileType floggraph nno <buffer> cv :<C-U>call flog#run_command("Git reset --mixed %h", 0, 1)<CR>
autocmd FileType floggraph nno <buffer> cV :<C-U>call flog#run_command("Git reset --hard %h", 0, 1)<CR>
v2
autocmd FileType floggraph nno <buffer> cv :<C-U>call flog#Exec("Git reset --mixed %h", 0, 1)<CR>
autocmd FileType floggraph nno <buffer> cV :<C-U>call flog#Exec("Git reset --hard %h", 0, 1)<CR>
This changes the cm
binding to automatically merge the first local branch under the cursor with the --no-ff
binding.
v1
autocmd FileType floggraph nno <buffer> cm :<C-U>call flog#run_command('Git merge %l --no-ff', 0, 1)<CR>
v2
autocmd FileType floggraph nno <buffer> cm :<C-U>call flog#Exec('Git merge %l --no-ff', 0, 1)<CR>
By default ]r
/[r
opens a split after jumping.
This disables that behaviour.
v1
autocmd FileType floggraph nno <buffer> <silent> ]r :<C-U>call flog#next_ref()<CR>
autocmd FileType floggraph nno <buffer> <silent> [r :<C-U>call flog#previous_ref()<CR>
v2
This is the default behavior in v2.
Fugitive has a problem with diff links when running any git diff
subcommand: see this related issue.
This is a workaround for that behavior.
v1
autocmd FileType floggraph nno <buffer> <silent> <Plug>(FlogVDiffSplitRight) :<C-U>call flog#run_tmp_command('vertical belowright Git show HEAD %h')<CR>
autocmd FileType floggraph vno <buffer> <silent> <Plug>(FlogVDiffSplitRight) :<C-U>call flog#run_tmp_command("vertical belowright Git show %(h'>) %(h'<)")<CR>
autocmd FileType floggraph nno <buffer> <silent> <Plug>(FlogVDiffSplitLastCommitRight) :<C-U> call flog#run_tmp_command("vertical belowright Git show %(h'!) %H")<CR>
v2
autocmd FileType floggraph nno <buffer> <silent> <Plug>(FlogVDiffSplitRight) :<C-U>call flog#ExecTmp('vertical belowright Git show HEAD %h', 0, 0)<CR>
autocmd FileType floggraph vno <buffer> <silent> <Plug>(FlogVDiffSplitRight) :<C-U>call flog#ExecTmp("vertical belowright Git show %(h'>) %(h'<)", 0, 0)<CR>
autocmd FileType floggraph nno <buffer> <silent> <Plug>(FlogVDiffSplitLastCommitRight) :<C-U> call flog#ExecTmp("vertical belowright Git show %(h'!) %H", 0, 0)<CR>