Adding BundleClean!

- BundleClean now requires confirmation
This commit is contained in:
gmarik 2011-01-22 17:17:05 -06:00
parent 75f14de912
commit 814c420ec2
3 changed files with 15 additions and 11 deletions

View File

@ -68,7 +68,7 @@ Searching requires [<code>curl</code>](http://curl.haxx.se/)
:BundleClean :BundleClean
removes unused script dirs from your `.vim/bundle` confirms removal of unused script dirs from your `.vim/bundle`. `BundleClean!` does that silently.
## Examples ## Examples

View File

@ -5,11 +5,11 @@
" Version: 0.5 " Version: 0.5
com! -nargs=+ Bundle call vundle#config#bundle(<args>) com! -nargs=+ Bundle call vundle#config#bundle(<args>)
com! -nargs=? -bang BundleInstall call vundle#installer#install("<bang>") com! -nargs=? -bang BundleInstall call vundle#installer#install('<bang>')
com! -nargs=? BundleClean call vundle#installer#clean() com! -nargs=? -bang BundleClean call vundle#installer#clean('<bang>')
com! -nargs=0 BundleDocs call vundle#installer#helptags() com! -nargs=0 BundleDocs call vundle#installer#helptags()
com! -nargs=+ -bang BundleSearch silent call vundle#scripts#search("<bang>", <q-args>) com! -nargs=+ -bang BundleSearch silent call vundle#scripts#search('<bang>', <q-args>)
func! vundle#rc() func! vundle#rc()
let g:bundle_dir = expand('$HOME/.vim/bundle') let g:bundle_dir = expand('$HOME/.vim/bundle')

View File

@ -10,6 +10,17 @@ func! vundle#installer#helptags()
call s:log('Done. '.c.' bundles processed') call s:log('Done. '.c.' bundles processed')
endf endf
func! vundle#installer#clean(bang)
let bundle_dirs = map(copy(g:bundles), 'v:val.path()')
let all_dirs = split(globpath(g:bundle_dir, '*'), "\n")
let x_dirs = filter(all_dirs, '0 > index(bundle_dirs, v:val)')
if (!empty(x_dirs))
if ('!' == a:bang || input('Are you sure you want to remove '.len(x_dirs).' bundles?') =~? 'y')
exec '!rm -rf '.join(map(x_dirs, 'shellescape(v:val)'), ' ')
endif
end
endf
func! s:reload_bundles() func! s:reload_bundles()
" TODO: obtain Bundles without sourcing .vimrc " TODO: obtain Bundles without sourcing .vimrc
silent source $MYVIMRC silent source $MYVIMRC
@ -42,13 +53,6 @@ func! s:install(bang, bundle)
if synced | call vundle#config#require(a:bundle) | endif if synced | call vundle#config#require(a:bundle) | endif
endf endf
func! vundle#installer#clean()
let bundle_dirs = map(copy(g:bundles), 'v:val.path()')
let all_dirs = split(globpath(g:bundle_dir, '*'), "\n")
let x_dirs = filter(all_dirs, '0 > index(bundle_dirs, v:val)')
for d in x_dirs | exec '!rm -rf "'.escape(d,'"').'"' | endfor
endf
" TODO: make it pause after output in console mode " TODO: make it pause after output in console mode
func! s:log(msg) func! s:log(msg)
if has('gui_running') if has('gui_running')