Skip to content

Instantly share code, notes, and snippets.

@aereal
Created March 19, 2010 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aereal/337371 to your computer and use it in GitHub Desktop.
Save aereal/337371 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# usage:
# $ git clone git://github.com/motemen/git-vim.git git-vim
# $ ruby vsm.rb git-vim/
VIMDIR = '~/.vim'
SRCDIR = ARGV[0]
require 'pathname'
require 'fileutils'
include FileUtils::Verbose
vimdirs = %w(
after
autoload
colors
compilers
dict
ftdetect
ftplugin
indent
keymap
lang
macros
plugin
spell
syntax
tools
tutor
)
vimdir, srcdir = *[VIMDIR, SRCDIR].map {|i| Pathname.new(i).expand_path }
[vimdir, srcdir].each {|i| i.mkpath }
def link(src, dst)
dst.parent.mkpath unless dst.parent.exist?
dst.delete if dst.symlink? || dst.file?
ln_sf src.to_s, dst.to_s
end
vimdirs.map {|i| vimdir + i }.each do |i|
next unless (working = srcdir + i).directory?
working.mkpath
working.children.each do |entry|
link(entry, i + entry.basename)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment