Skip to content

Instantly share code, notes, and snippets.

@aereal aereal/vsm.rb
Created Mar 19, 2010

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.