Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ non-git projects) and previous sessions should automatically be reloaded.

### Options

#### Automatically create sessions

If you don't want to have to `:GitSaveSession` you can:

let g:gitsessions_auto_create_sessions = 1

in your .vimrc and a session will be created for you automatically
on exit if it doesn't already exist. If it does already exist then
it will be updated on exit as usual.

#### Change sessions save location

Default session directory is `~/.vim/sessions` and can be modified in `.vimrc`:
Expand Down
18 changes: 16 additions & 2 deletions plugin/gitsessions.vim
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,27 @@ function! g:GitSessionDelete()
endif
endfunction

function! g:GitSessionSaveOnExit()
if s:in_git_repo()
if g:gitsessions_auto_create_sessions
return GitSessionSave()
else
return GitSessionUpdate()
endif
endif
endfunction

augroup gitsessions
autocmd!
if ! exists("g:gitsessions_disable_auto_load")
autocmd VimEnter * :call g:GitSessionLoad()
if exists("g:gitsessions_use_nested_load")
autocmd VimEnter * nested :call g:GitSessionLoad()
else
autocmd VimEnter * :call g:GitSessionLoad()
endif
endif
autocmd BufEnter * :call g:GitSessionUpdate(0)
autocmd VimLeave * :call g:GitSessionUpdate()
autocmd VimLeave * :call g:GitSessionSaveOnExit()
augroup END

command GitSessionSave call g:GitSessionSave()
Expand Down