Skip to content

Instantly share code, notes, and snippets.

@bleything
Created January 2, 2013 00:32
Embed
What would you like to do?
Stick this in your homedir repo. Run rake. Watch in amazement as it symlinks everything.
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
@fooblahblah
Copy link

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" ;

@briandoll
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment