Created
August 6, 2010 07:55
-
-
Save gaving/511011 to your computer and use it in GitHub Desktop.
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/clean' | |
require 'rake/testtask' | |
require 'fileutils' | |
require 'date' | |
def stop_error(message) | |
puts "ERROR: #{message}" | |
exit(1) | |
end | |
def symlink(target, link) | |
puts "Linking #{link} => #{target}" | |
if File.symlink?(link) | |
puts " * deleting existing symlink #{link}" | |
File.unlink(link) | |
elsif File.exist?(link) | |
stop_error("File exists: #{link}") | |
end | |
File.symlink(target, link) | |
puts | |
end | |
desc "Install all dotfiles" | |
task :install do | |
home = ENV['HOME'] | |
pwd = File.dirname(__FILE__) | |
FileList['.*'].exclude(/^(\.{1,2}|.git)$/).each do |file| | |
symlink("#{pwd}/#{file}", "#{home}/#{file}") | |
end | |
end | |
task :sync_home do | |
puts "Syncing files to home" | |
sh <<-SH | |
mv /h/Dotfiles /h/Dotfiles_bak_#{Date.today.to_s} | |
SH | |
sh <<-SH | |
rsync \ | |
--exclude=.git \ | |
--exclude=custom \ | |
--exclude=history \ | |
--delete \ | |
--copy-links \ | |
-ruv \ | |
. \ | |
/h/Dotfiles | |
SH | |
sh <<-SH | |
rsync --delete -ruv /h/Dotfiles/.vim/ /h/.vim | |
SH | |
sh <<-SH | |
cp /h/Dotfiles/.vimrc /h/.vimrc | |
SH | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment