nvim: autoload/git: Generate a helpful name to use with stash

This commit is contained in:
Sanchayan Maity 2022-01-19 17:41:28 +05:30
parent e807b1126a
commit 3cf20c4822
2 changed files with 9 additions and 1 deletions

View file

@ -24,7 +24,7 @@ nnoremap <Leader>gn :Git branch -m<SPACE>
nnoremap <Leader>go :call git#git_log_compare()<CR>
nnoremap <Leader>gr :call git#git_rebase_origin()<CR>
nnoremap <Leader>gR :Git rebase --abort<CR>
nnoremap <Leader>g- :Git stash<CR>:e<CR>
nnoremap <Leader>g- :call git#git_stash()<CR>:e<CR>
nnoremap <Leader>g+ :Git stash pop<SPACE>
nnoremap <Leader>gs :Git stash list<CR>
nnoremap <Leader>gS :Git stash -- %<CR>

View file

@ -241,3 +241,11 @@ function! git#git_rebase_origin() abort
echom "Rebasing current branch on origin/" . default[3]
execute "Git rebase origin/" . default[3]
endfunction
" Generate a helpful name when using Git stash
function! git#git_stash() abort
let current = trim(system("git branch --show-current"))
let current_time = strftime("%Y-%b-%d_%H-%M")
let stash_name = current . "-" . current_time
execute "Git stash push -m " . stash_name
endfunction