diff --git a/README.md b/README.md index d8c3648..e287616 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ Searching requires [curl](http://curl.haxx.se/) :BundleClean -removes unused script dirs from your `.vim/bundle` +confirms removal of unused script dirs from your `.vim/bundle`. `BundleClean!` does that silently. ## Examples diff --git a/autoload/vundle.vim b/autoload/vundle.vim index 84b4e83..3fd1962 100644 --- a/autoload/vundle.vim +++ b/autoload/vundle.vim @@ -5,11 +5,11 @@ " Version: 0.5 com! -nargs=+ Bundle call vundle#config#bundle() -com! -nargs=? -bang BundleInstall call vundle#installer#install("") -com! -nargs=? BundleClean call vundle#installer#clean() +com! -nargs=? -bang BundleInstall call vundle#installer#install('') +com! -nargs=? -bang BundleClean call vundle#installer#clean('') com! -nargs=0 BundleDocs call vundle#installer#helptags() -com! -nargs=+ -bang BundleSearch silent call vundle#scripts#search("", ) +com! -nargs=+ -bang BundleSearch silent call vundle#scripts#search('', ) func! vundle#rc() let g:bundle_dir = expand('$HOME/.vim/bundle') diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 1786d0c..cdec6bb 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -10,6 +10,17 @@ func! vundle#installer#helptags() call s:log('Done. '.c.' bundles processed') 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() " TODO: obtain Bundles without sourcing .vimrc silent source $MYVIMRC @@ -42,13 +53,6 @@ func! s:install(bang, bundle) if synced | call vundle#config#require(a:bundle) | endif 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 func! s:log(msg) if has('gui_running')