Skip to content

Instantly share code, notes, and snippets.

@kdwinter
Created March 29, 2009 13:41
Show Gist options
  • Save kdwinter/87399 to your computer and use it in GitHub Desktop.
Save kdwinter/87399 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby19
# encoding: utf-8
require 'fileutils'
module ToGit
Gitdir = File.join( ENV['HOME'], 'github/dotfiles' )
class << self
Git = lambda { |command, dir| `git --git-dir=#{dir}/.git #{command}` }
def copy_and_add( args )
raise 'No file specified' if args.empty?
args.each do |file|
src = File.expand_path( file )
dst = File.expand_path( File.join( Gitdir, file ) )
FileUtils.cp_r( src, dst )
Git.( "add #{file}", Gitdir )
end
end
end
end
ToGit.copy_and_add(ARGV)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment