forked from skwp/dotfiles
-
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.
Merge pull request skwp#13 from kylewest/simple-automated-install
Simple automated installer. Use: rake install
- Loading branch information
Showing
15 changed files
with
286 additions
and
240 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
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
require 'rake' | ||
|
||
desc "Hook our dotfiles into system-standard positions." | ||
task :install => :submodules do | ||
# this has all the linkables from this directory. | ||
linkables = [] | ||
linkables += Dir.glob('git/*') if want_to_install?('git') | ||
linkables += Dir.glob('irb/*') if want_to_install?('irb/pry') | ||
linkables += Dir.glob('{vim,vimrc}') if want_to_install?('vim') | ||
linkables += Dir.glob('zsh/zshrc') if want_to_install?('zsh') | ||
|
||
skip_all = false | ||
overwrite_all = false | ||
backup_all = false | ||
|
||
linkables.each do |linkable| | ||
file = linkable.split('/').last | ||
source = "#{ENV["PWD"]}/#{linkable}" | ||
target = "#{ENV["HOME"]}/.#{file}" | ||
|
||
puts "--------" | ||
puts "file: #{file}" | ||
puts "source: #{source}" | ||
puts "target: #{target}" | ||
|
||
if File.exists?(target) || File.symlink?(target) | ||
unless skip_all || overwrite_all || backup_all | ||
puts "File already exists: #{target}, what do you want to do? [s]kip, [S]kip all, [o]verwrite, [O]verwrite all, [b]ackup, [B]ackup all" | ||
case STDIN.gets.chomp | ||
when 'o' then overwrite = true | ||
when 'b' then backup = true | ||
when 'O' then overwrite_all = true | ||
when 'B' then backup_all = true | ||
when 'S' then skip_all = true | ||
end | ||
end | ||
FileUtils.rm_rf(target) if overwrite || overwrite_all | ||
`mv "$HOME/.#{file}" "$HOME/.#{file}.backup"` if backup || backup_all | ||
end | ||
`ln -s "#{source}" "#{target}"` | ||
end | ||
success_msg("installed") | ||
end | ||
|
||
desc "Init and update submodules." | ||
task :submodules do | ||
sh('git submodule update --init') | ||
end | ||
|
||
task :default => 'install' | ||
|
||
|
||
private | ||
|
||
def want_to_install? (section) | ||
puts "Would you like to install configuration files for: #{section}? [y]es, [n]o" | ||
STDIN.gets.chomp == 'y' | ||
end | ||
|
||
def success_msg(action) | ||
puts "" | ||
puts " _ _ _ " | ||
puts " | | | | | | " | ||
puts " | |___| |_____ __| | ____ " | ||
puts " |_____ (____ |/ _ |/ ___) " | ||
puts " _____| / ___ ( (_| | | " | ||
puts " (_______\_____|\____|_| " | ||
puts "" | ||
puts "YADR has been #{action}. Please restart your terminal and vim." | ||
end |
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,2 +1,4 @@ | ||
Dir[File.join(File.dirname(__FILE__),"lib/**/lib")].each {|dir| $LOAD_PATH << dir} | ||
require 'git-style-binary/command' | ||
|
||
$yadr = `find -L ~ -type file -maxdepth 2 -name .yadr | head | sed 's:\.yadr\/::'`.chomp |
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
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
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
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
Oops, something went wrong.