Created
April 9, 2012 13:57
-
-
Save mattsgarrison/2343599 to your computer and use it in GitHub Desktop.
Rake task to link up my Dotfiles repo.
This file contains 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 'pathname' | |
require 'fileutils' | |
#This assumes this script is your home directory level Rakefile | |
namespace :dotfiles do | |
desc "Link ALL the dotfiles!" | |
task :link do | |
path = Pathname.new("#{__FILE__}").dirname | |
Dir.glob "#{path}/Dotfiles/*" do |f| | |
new_file = "#{ENV['HOME']}/.#{File.basename(f)}" | |
if FileTest.exists?("#{new_file}") | |
FileUtils.mv new_file, "#{new_file}.#{Time.now.to_i}.old" | |
end | |
system "ln -s #{f} #{new_file}" | |
end | |
end | |
desc "Install the Dotfiles repo" | |
task :install do | |
Dir.chdir(Pathname.new(__FILE__).dirname) | |
system 'git clone [email protected]:mattsgarrison/Dotfiles.git' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment