-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a list of directories not to symlink with dots
- Loading branch information
Showing
1 changed file
with
16 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,28 @@ | ||
# Adapted from Ryan Bates's dotfiles rakefile | ||
# https://github.com/ryanb/dotfiles | ||
|
||
require 'rake' | ||
require 'fileutils' | ||
|
||
desc "install dotfiles" | ||
IGNORES = %w{Rakefile README.md LICENSE} | ||
NO_DOTS = %w{bin} | ||
|
||
task :default => :install | ||
|
||
desc "install dotfiles" | ||
task :install do | ||
Dir['*'].each do |file| | ||
next if %w[Rakefile README.md LICENSE].include? file | ||
path = File.join(ENV['HOME'], ".#{file}") | ||
next if IGNORES.include? file | ||
path = install_path_for file | ||
if File.exist?(path) || File.symlink?(path) | ||
puts "removing existing ~/.#{file}" | ||
system %Q{rm -rf "$HOME/.#{file}"} | ||
puts "Removing #{path}" | ||
FileUtils.rm_rf path | ||
end | ||
puts "linking ~/.#{file}" | ||
system %Q{ln -s "$PWD/#{file}" "$HOME/.#{file}"} | ||
puts "Linking #{path}" | ||
FileUtils.ln_s File.join(Dir.pwd, file), path | ||
end | ||
end | ||
|
||
def install_path_for file | ||
basename = (NO_DOTS.include? file) && file || ".#{file}" | ||
File.join(ENV['HOME'], basename) | ||
end |