Created
January 2, 2013 00:32
-
-
Save bleything/4431293 to your computer and use it in GitHub Desktop.
Stick this in your homedir repo. Run rake. Watch in amazement as it symlinks everything.
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 'find' | |
BLACKLIST = %w[ | |
.git | |
.gitignore | |
Rakefile | |
] | |
task :default do | |
Find.find('.') do |path| | |
next if path == '.' | |
Find.prune if BLACKLIST.include? path.sub(%r{^\./}, '') | |
if File.directory? path | |
dir = File.expand_path("~/#{path}") | |
system "mkdir -p #{dir}" | |
next | |
elsif File.file? path | |
source = File.expand_path("../#{path}", __FILE__) | |
target = File.expand_path("~/#{path}") | |
system "ln -sf '#{source}' '#{target}'" | |
else | |
puts "Don't know how to deal with '#{path}', it's not a dir or file." | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does this do the same-ish thing?
$ find . -type d -exec echo "mkdir -p /tmp/{}" ; -or -type f -exec echo "ln -sf /tmp/{}" ; -or -type l -exec echo "ln -sf /tmp/{}" ; -or -exec echo "**** {} not sure" ;