Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

63 lines (52 sloc) 1.379 kb
require 'rake'
# added comment
desc "install the dot files into user's home directory"
task :install do
name = `git config --global user.name`.strip
email = `git config --global user.email`.strip
# git config --global user.name "Lawrence"
replace_all = false
Dir['*'].each do |file|
next if %w[Rakefile README LICENSE].include? file
if File.exist?(File.join(ENV['HOME'], ".#{file}"))
if replace_all
replace_file(file)
else
print "overwrite ~/.#{file}? [ynaq] "
case $stdin.gets.chomp
when 'a'
replace_all = true
replace_file(file)
when 'y'
replace_file(file)
when 'q'
exit
else
puts "skipping ~/.#{file}"
end
end
else
link_file(file)
end
end
puts "Name: (leave blank to default to '#{name}')"
new_name = STDIN.gets.strip
puts "Email: (leave blank to default to '#{email}')"
new_email = STDIN.gets.strip
if new_email == ""
new_email = email
end
if new_name == ""
new_name = name
end
`git config --global user.name "#{new_name}"`
`git config --global user.email "#{new_email}"`
end
def replace_file(file)
system %Q{rm "$HOME/.#{file}"}
link_file(file)
end
def link_file(file)
puts "linking ~/.#{file}"
system %Q{ln -s "$PWD/#{file}" "$HOME/.#{file}"}
end
Jump to Line
Something went wrong with that request. Please try again.