# HG changeset patch # User Meredith Howard # Date 1404267729 14400 # Node ID f4808ae73ead9aeab203d7a233346ab0db0141ce # Parent 6c1ea6e90a2302bcf1d54b0b35164a5b5a1b389c clean up diff --git a/.homedir-setup.rb b/.homedir-setup.rb --- a/.homedir-setup.rb +++ b/.homedir-setup.rb @@ -1,6 +1,5 @@ #!/usr/bin/env ruby # vim: et sts=2 sw=2 fdm=marker -# encoding: UTF-8 # we don't yet have rbenv so keep safe for ruby 1.8 @@ -10,69 +9,14 @@ if `which git` == '' end -# util {{{ - # just checks and bails after each call - def do_cmds (*cmds) - cmds.each do |cmd| - puts "$ #{cmd}" - system( cmd ) or exit $? - end +# just checks and bails after each call +def do_cmds (*cmds) + cmds.each do |cmd| + puts "$ #{cmd}" + system( cmd ) or exit $? end - - #checks for the first line and if it's not there, appends the whole set - def add_if_missing (fn, lines) - match = lines.lines.first.chomp - add = false - - if File.exists?(fn) - File.open(fn) do |file| - if file.each_line.none? { |line| line.chomp == match } - add = true - end - end - else - add = true - end - - if add == true - File.open(fn, 'a') do |append| - append << lines - append << $/ - end +end - puts "Added to #{fn}:" - puts lines + $/ - end - - end - - def replace_line (fn, match, replace) - buf = [] - changed = false - - File.open(fn) do |file| - file.each_line do |line| - buf << if line.match(match) - changed = true - replace - else - line - end - end - end - - if changed - File.open( fn + ".tmp~", 'w' ) do |file| - buf.each do |line| - file.puts line - end - end - puts 'changes in #{fn}.tmp~' - else - puts 'no change' - end - end -# }}} # oh-my-zsh {{{ @@ -86,7 +30,6 @@ end puts "Installing oh-my-zsh..." do_cmds \ - 'rm -r .oh-my-zsh', 'git clone git://github.com/robbyrussell/oh-my-zsh.git .oh-my-zsh', 'hg stat -dn0 -I .oh-my-zsh/ | xargs -0 hg revert' @@ -95,14 +38,6 @@ end # }}} -add_if_missing '.bash_profile', 'export PATH=~/bin:$PATH' - -add_if_missing '.zshrc', <> ~/.bash_profile -# echo 'eval "$(rbenv init -)"' >> ~/.bash_profile if Dir.exists?('.rbenv') puts "rbenv already installed" else @@ -145,27 +64,8 @@ END 'git clone https://github.com/sstephenson/rbenv.git .rbenv', 'git clone https://github.com/sstephenson/ruby-build.git .rbenv/plugins/ruby-build/' - - add_if_missing '.bash_profile', <