diff --git a/Rakefile b/Rakefile index b97f50122a..4a259b0b8a 100644 --- a/Rakefile +++ b/Rakefile @@ -11,13 +11,13 @@ task :install do files << "oh-my-zsh/custom/rbates.zsh-theme" files.each do |file| system %Q{mkdir -p "$HOME/.#{File.dirname(file)}"} if file =~ /\// - if File.exist?(File.join(ENV['HOME'], ".#{file.sub('.erb', '')}")) - if File.identical? file, File.join(ENV['HOME'], ".#{file.sub('.erb', '')}") - puts "identical ~/.#{file.sub('.erb', '')}" + if File.exist?(File.join(ENV['HOME'], ".#{file.sub(/\.erb$/, '')}")) + if File.identical? file, File.join(ENV['HOME'], ".#{file.sub(/\.erb$/, '')}") + puts "identical ~/.#{file.sub(/\.erb$/, '')}" elsif replace_all replace_file(file) else - print "overwrite ~/.#{file.sub('.erb', '')}? [ynaq] " + print "overwrite ~/.#{file.sub(/\.erb$/, '')}? [ynaq] " case $stdin.gets.chomp when 'a' replace_all = true @@ -27,7 +27,7 @@ task :install do when 'q' exit else - puts "skipping ~/.#{file.sub('.erb', '')}" + puts "skipping ~/.#{file.sub(/\.erb$/, '')}" end end else @@ -37,14 +37,14 @@ task :install do end def replace_file(file) - system %Q{rm -rf "$HOME/.#{file.sub('.erb', '')}"} + system %Q{rm -rf "$HOME/.#{file.sub(/\.erb$/, '')}"} link_file(file) end def link_file(file) if file =~ /.erb$/ - puts "generating ~/.#{file.sub('.erb', '')}" - File.open(File.join(ENV['HOME'], ".#{file.sub('.erb', '')}"), 'w') do |new_file| + puts "generating ~/.#{file.sub(/\.erb$/, '')}" + File.open(File.join(ENV['HOME'], ".#{file.sub(/\.erb$/, '')}"), 'w') do |new_file| new_file.write ERB.new(File.read(file)).result(binding) end elsif file =~ /zshrc$/ # copy zshrc instead of link