Created
October 5, 2011 17:44
-
-
Save carlzulauf/1265124 to your computer and use it in GitHub Desktop.
Rake task to install dot files into home directory as symlinks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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