Programatically install Vim bundles
I have a simple bash script I use to normalise my shell on various computers. There are a selection of Vim plugins I couldn't live without, and therefore scripted up a basic Vim plugin install pattern that I use as part of the script that copies my various dotfiles into a system.
I've split the install process for each plugin into a separate file, and call them like:
#!/bin/bash
# filename: copy.sh
vim/install-pathogen.sh
vim/install-gitgutter.sh
vim/install-fugitive.sh
vim/install-neocomplcache.shPathogen is required for many plugins, so it is installed first. The contents of vim/install-pathogen.sh:
#!/bin/bash
PATHOGEN="~/.vim/autoload/pathogen.vim"
# First make sure pathogen isn't present
if [ ! -f "`eval echo ${DIRECTORY//>}`" ]; then
    # I've simply copied the pathogen install steps from the README
    mkdir -p ~/.vim/autoload ~/.vim/bundle; \
    curl -Sso ~/.vim/autoload/pathogen.vim \
        https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
fiFinally, an example of installing a plugin:
#!/bin/bash
DIRECTORY="~/.vim/bundle/vim-gitgutter"
# Again, ensure the plugin hasn't been installed yet
if [ ! -d "`eval echo ${DIRECTORY//>}`" ]; then
    cd ~/.vim/bundle
    git clone git://github.com/airblade/vim-gitgutter.git
fiWritten by Michael Robinson
Related protips
2 Responses
 
Unless you have plugins with build/install stages, isn't this easier to do with git submodules? I do just that for my Vim setup and clone it from GitHub whenever I have to get my Vim environment.
 
Good point gaveen, that would work well. I'm planning on moving plugin-specific ~/.vimrc config into the install scripts as well, as since starting to use a bunch of plugins my ~/.vimrc file has become rather unwieldy.
 
 
 
