Skip to content

Instantly share code, notes, and snippets.

@mattsgarrison
Created April 9, 2012 13:57
Show Gist options
  • Save mattsgarrison/2343599 to your computer and use it in GitHub Desktop.
Save mattsgarrison/2343599 to your computer and use it in GitHub Desktop.
Rake task to link up my Dotfiles repo.
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 git@github.com:mattsgarrison/Dotfiles.git'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment