Skip to content

Commit

Permalink
add :SDelete
Browse files Browse the repository at this point in the history
  • Loading branch information
mhinz committed May 2, 2013
1 parent 48d748c commit d671a09
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<c-u>` and `<tab>`.
Expand Down
21 changes: 21 additions & 0 deletions autoload/startify.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions doc/startify.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -189,6 +190,7 @@ Don't show <empty buffer> and <quit>.

: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.
Expand Down
5 changes: 3 additions & 2 deletions plugin/startify.vim
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ augroup startify
\ endif
augroup END

command! -nargs=? -bar -complete=customlist,startify#get_session_names SSave call startify#save_session(<f-args>)
command! -nargs=? -bar -complete=customlist,startify#get_session_names SLoad call startify#load_session(<f-args>)
command! -nargs=? -bar -complete=customlist,startify#get_session_names SSave call startify#save_session(<f-args>)
command! -nargs=? -bar -complete=customlist,startify#get_session_names SLoad call startify#load_session(<f-args>)
command! -nargs=? -bar -complete=customlist,startify#get_session_names SDelete call startify#delete_session(<f-args>)
command! -nargs=0 -bar Startify enew | call s:insane_in_the_membrane()

" Function: s:insane_in_the_membrane {{{1
Expand Down

0 comments on commit d671a09

Please sign in to comment.