Skip to content

Instantly share code, notes, and snippets.

@carlzulauf
Created October 5, 2011 17:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlzulauf/1265124 to your computer and use it in GitHub Desktop.
Save carlzulauf/1265124 to your computer and use it in GitHub Desktop.
Rake task to install dot files into home directory as symlinks
require 'rake'
desc "Install dot files as symbolic links"
task :install do
dots = File.join(Dir.getwd, "home")
home = Dir.home
backup = File.join(home, ".backup-dotfiles")
Dir.mkdir(backup) unless File.directory?(backup)
files = Dir.entries(dots) - [".", ".."]
files.each do |file|
src = File.join(dots, file)
dest = File.join(home, file)
unless File.symlink?(dest)
if File.exists?(dest)
puts "Moving existing #{file} to #{backup}"
system "mv #{dest} #{backup}"
end
puts "Linking #{file}"
system "ln -s #{src} #{dest}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment