From 6b54e1eec6011184aa8df8215e0ef0b1115d668b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 14 Jan 2021 15:38:31 +0100 Subject: [PATCH] Add more vim fugitive commands --- symlinks/vim/plugin/fugitive.vim | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/symlinks/vim/plugin/fugitive.vim b/symlinks/vim/plugin/fugitive.vim index 7e4687f..4ddecc2 100644 --- a/symlinks/vim/plugin/fugitive.vim +++ b/symlinks/vim/plugin/fugitive.vim @@ -44,8 +44,25 @@ function! s:OpenNewPr() call netrw#BrowseX(s:GetPrUrl(), 0) endfunction +" Creates new branch and checks out to it +" Similar to `gcb` in fish config +function! s:CreateBranch(branch) + execute 'Git checkout -b ' . a:branch +endfunction + +" Switches to branch +function! s:CheckoutBranch(branch) + execute 'Git checkout ' . a:branch +endfunction + command! -nargs=0 Ggpush :call s:PushOrigin() -command! -nargs=0 Gpr :call s:OpenNewPr() command! -nargs=0 Gpropen :call s:OpenNewPr() +command! -nargs=0 Gpr Gpropen command! -nargs=0 Gprprint :call s:PrintPrUrl() command! -nargs=0 Gprcopy :call s:CopyPrUrl() +command! -nargs=1 Gcbranch :call s:CreateBranch() +command! -nargs=0 Gcmaster :call s:CheckoutBranch('main') +command! -nargs=0 Gcm Gcmaster +command! -nargs=0 Gcdev :call s:CheckoutBranch('develop') +command! -nargs=1 Gcheckout :call s:CheckoutBranch() +command! -nargs=1 Gc Gcheckout