Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 30a81b992e
Fetching contributors…

Cannot retrieve contributors at this time

file 70 lines (61 sloc) 1.455 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
class Installer
  def symlink(target, link)
    if File.symlink?(link)
      unlink(link)
    elsif File.exist?(link)
      puts "ERROR: File exists: #{link}"
      exit 1
    end
    puts "Symlinking #{link} => #{target}"
    File.symlink(target, link)
  end

  def delete_symlink(link)
    unlink(link) if File.symlink?(link)
  end

  def unlink(link)
    if File.exist?(link)
      descriptor = File.symlink?(link) ? "symlink" : "file"
      puts "Deleting #{descriptor} #{link}"
      File.unlink(link)
    end
  end
end

def pwd; File.dirname(__FILE__); end
def target_path(file)
  File.join(ENV["HOME"], ".#{file}")
end

files = File.new(File.join(pwd, "MANIFEST"), "r").read.split("\n")

desc "Install all dotfiles"
task :install => [:init_submodules, :update_submodules] do
  files.each do |file|
    Installer.new.symlink(File.join(pwd, file), target_path(file))
  end
end

desc "Remove all dotfies"
task :uninstall do
  files.each do |file|
    Installer.new.unlink(target_path(file))
  end
end

desc "Install submodules"
task :init_submodules do
  puts "Installing submodules"
  `git submodule init`
end

desc "Update submodules"
task :update_submodules do
  puts "Updating submodules"
  `git submodule update`
end

desc "Pull in new vim submodules"
task :pull_vim_submodules do
  puts "Pull vim submodules"
  system(%{
for x in vim/bundle/*; do
echo $x
cd $x
git co master && git pull
cd ../../..
done
})
end
Something went wrong with that request. Please try again.