# HG changeset patch # User Meredith Howard # Date 1625596446 18000 # Node ID c1cc35d1859717584b89edcd96e1511f8618acbc # Parent 79348384a55e316df2e8781005d2a58bdbd0329d Add PruneSession diff --git a/.vim/autoload/vimrc.vim b/.vim/autoload/vimrc.vim --- a/.vim/autoload/vimrc.vim +++ b/.vim/autoload/vimrc.vim @@ -87,3 +87,20 @@ func! vimrc#SafeFilterFile(cmd) call delete(errors) endtry endfunc + +if has('perl') + func! vimrc#PruneSession() abort + perl <Name || -d _ || (-M _ >= 30) } + grep { $_->Name } VIM::Buffers(); + + while (my $b = shift @bufs) { + VIM::Msg 'pruned: ' . $b->Name, 'Comment'; + VIM::DoCommand 'bwipeout ' . $b->Number; + } + VIM::DoCommand 'bprev' + unless $curbuf->Name; +END_PERL + endfunc +endif diff --git a/.vimrc b/.vimrc --- a/.vimrc +++ b/.vimrc @@ -141,6 +141,7 @@ command! Hgcd call vimrc#Hgcd() command! SyntaxCompleteOn setl omnifunc=syntaxcomplete#Complete command! Mksession execute "mksession! " . v:this_session +command! PruneSession call vimrc#PruneSession() command! -nargs=* -complete=file Tig call tig#Tig() command! TigBlame call tig#TigBlame()