diff --git a/README.md b/README.md index d449971..40babfb 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ _2)_ It eases handling of loading and saving sessions by only working with a :SLoad load a session :SSave save a session + :SDelete delete a session _NOTE_: Both commands can also take session names directly as an argument. You can also make use of completion via `` and ``. diff --git a/autoload/startify.vim b/autoload/startify.vim index 81faeb3..dad1b95 100644 --- a/autoload/startify.vim +++ b/autoload/startify.vim @@ -32,6 +32,27 @@ function! startify#is_in_skiplist(arg) abort endfor endfunction +function! startify#delete_session(...) abort + if !isdirectory(g:startify_session_dir) + echo 'The session directory does not exist: '. g:startify_session_dir + return + endif + let spath = g:startify_session_dir . startify#get_separator() . (exists('a:1') + \ ? a:1 + \ : input('Delete this session: ', '', 'custom,startify#get_session_names_as_string')) + \ | redraw + echo 'Really delete '. spath .'? [y/n]' | redraw + if (nr2char(getchar()) == 'y') + if delete(spath) == 0 + echo 'Deleted session '. spath .'!' + else + echo 'Deletion failed!' + endif + else + echo 'Deletion aborted!' + endif +endfunction + function! startify#save_session(...) abort if !isdirectory(g:startify_session_dir) if exists('*mkdir') diff --git a/doc/startify.txt b/doc/startify.txt index 5d0ba36..9cb5a4d 100644 --- a/doc/startify.txt +++ b/doc/startify.txt @@ -62,6 +62,7 @@ Startify basically provides two things: :SLoad load a session :SSave save a session + :SDelete delete a session The default settings are pretty sane, so it should work without any configuration. @@ -189,6 +190,7 @@ Don't show and . :SLoad load a session :SSave save a session + :SDelete delete a session These take either 0 or 1 argument. If you don't specify the session name as an argument, they will just ask for it. diff --git a/plugin/startify.vim b/plugin/startify.vim index f0b0ff0..d090e92 100644 --- a/plugin/startify.vim +++ b/plugin/startify.vim @@ -29,8 +29,9 @@ augroup startify \ endif augroup END -command! -nargs=? -bar -complete=customlist,startify#get_session_names SSave call startify#save_session() -command! -nargs=? -bar -complete=customlist,startify#get_session_names SLoad call startify#load_session() +command! -nargs=? -bar -complete=customlist,startify#get_session_names SSave call startify#save_session() +command! -nargs=? -bar -complete=customlist,startify#get_session_names SLoad call startify#load_session() +command! -nargs=? -bar -complete=customlist,startify#get_session_names SDelete call startify#delete_session() command! -nargs=0 -bar Startify enew | call s:insane_in_the_membrane() " Function: s:insane_in_the_membrane {{{1