sponsor Vim development Vim logo Vim Book Ad

Install a Plugin in Vim : symlinks don\\'t overwrite existing files, uninstall only deletes symlinks

 script karma  Rating 2/2, Downloaded by 730  Comments, bugs, improvements  Vim wiki

created by
Questions toask
 
script type
ftplugin
 
description
# Easily install vim plugins from a source control checkout (e.g. Github)
#
# alias vim-install=rake -f ~/.vim/rakefile-vim-install
# vim-install
# vim-install uninstall
# will be Trying for http://questionstoaskagirlguy.com/
require \\\\\\'ftools\\\\\\'
require \\\\\\'fileutils\\\\\\'

task :default => :install
desc \\\\\\\"Install a vim plugin the lazy way\\\\\\\"
task :install do
  vim_dir      = File.expand_path(\\\\\\\"~/.vim\\\\\\\")
  plugin_dir   = Dir.pwd

  if not (FileTest.exists? File.join(plugin_dir,\\\\\\\".git\\\\\\\") or
          FileTest.exists? File.join(plugin_dir,\\\\\\\".svn\\\\\\\") or
          FileTest.exists? File.join(plugin_dir,\\\\\\\".hg\\\\\\\"))
      puts \\\\\\\"#{plugin_dir} isn\\\\\\'t a source controlled directory. Aborting.\\\\\\\"
      exit 1
  end

  Dir[\\\\\\'**/\\\\\\'].each do |d|
    FileUtils.mkdir_p File.join(vim_dir, d)
  end

  Dir[\\\\\\\"**/*.{txt,snippet,snippets,vim,js,wsf}\\\\\\\"].each do |f|
    ln File.join(plugin_dir, f), File.join(vim_dir,f)
  end

  boldred = \\\\\\\"\\\\\\\\033[1;31m\\\\\\\"
  clear = \\\\\\\"\\\\\\\\033[0m\\\\\\\"
  puts \\\\\\\"\\\\\\\\nDone. Remember to #{boldred}:helptags ~/.vim/doc#{clear}\\\\\\\"
end

task :uninstall do
  vim_dir      = File.expand_path(\\\\\\\"~/.vim\\\\\\\")
  plugin_dir   = Dir.pwd
  Dir[\\\\\\\"**/*.{txt,snippet,snippets,vim}\\\\\\\"].each do |f|
    safe_rm File.join(vim_dir, f)
  end
end

def nicename(path)
    boldgreen = \\\\\\\"\\\\\\\\033[1;32m\\\\\\\"
    clear = \\\\\\\"\\\\\\\\033[0m\\\\\\\"
    return \\\\\\\"#{boldgreen}#{File.join(path.split(\\\\\\'/\\\\\\')[-2..-1])}#{clear}\\\\\\\\t\\\\\\\"
end

def ln(src, dst)
    begin
        FileUtils.ln_s src, dst
        puts \\\\\\\"    Symlink #{nicename src}\\\\\\\\t => #{nicename dst}\\\\\\\"
    rescue Errno::EEXIST
        puts \\\\\\\"  #{nicename dst} exists! Skipping.\\\\\\\"
    end
end

def cp(src, dst)
  puts \\\\\\\"    Copying #{nicename src}\\\\\\\\t=> #{nicename dst}\\\\\\\"
  FileUtils.cp src, dst
end

def safe_rm(target)
    if FileTest.exists? target and FileTest.symlink? target
        puts \\\\\\\"    #{nicename target} removed.\\\\\\\"
        File.delete target
    else
        puts \\\\\\\"  #{nicename target} is not a symlink. Skipping\\\\\\\"
    end
end
 
install details
I think you should have a look at the Pathogen plugin. After you have this installed, you can keep all of your plugins in separate folders in ~/.vim/bundle/, and Pathogen will take care of loading them.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
Vim Script.png cp 2016-10-30 7.0 Questions toask Initial upload
ip used for rating: 44.220.184.63

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github