Permalink
Browse files

add other config files

  • Loading branch information...
1 parent 7eb45c5 commit 0c6d5663e0a6b2e80e6334b9f654393754d4c132 Thomas Queste committed Apr 7, 2011
Showing with 113 additions and 0 deletions.
  1. +50 −0 Rakefile
  2. +10 −0 ackrc
  3. +19 −0 gitignore
  4. +12 −0 irbrc
  5. +22 −0 railsrc
View
@@ -0,0 +1,50 @@
+require 'rake'
+require 'erb'
+
+desc "install the dot files into user's home directory"
+task :install do
+ replace_all = false
+ Dir['*'].each do |file|
+ next if %w[Rakefile README.md LICENSE].include? 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', '')}"
+ elsif replace_all
+ replace_file(file)
+ else
+ print "overwrite ~/.#{file.sub('.erb', '')}? [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.sub('.erb', '')}"
+ end
+ end
+ else
+ link_file(file)
+ end
+ end
+end
+
+def replace_file(file)
+ 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|
+ new_file.write ERB.new(File.read(file)).result(binding)
+ end
+ else
+ puts "linking ~/.#{file}"
+ system %Q{ln -s "$PWD/#{file}" "$HOME/.#{file}"}
+ end
+end
View
10 ackrc
@@ -0,0 +1,10 @@
+--type-set=haml=.haml
+--type-set=sass=.sass,.scss
+
+--type-add=ruby=.haml,.rake
+--type-add=html=.html.erb,.html.haml
+--type-add=css=.sass,.scss,.less
+
+--smart-case
+--sort-files
+
View
@@ -0,0 +1,19 @@
+# Tmp dir and Tmp files
+tmp/**/*
+.*.swp
+*~
+
+# Logs
+*.log
+
+# Databases
+*.sqlite3
+*.sqlite
+
+# OS generated files
+.DS_Store?
+Thumbs.db
+
+# SVN
+.svn
+
View
12 irbrc
@@ -0,0 +1,12 @@
+#!/usr/bin/ruby
+
+require 'rubygems' unless defined? Gem
+# IrbTools : https://github.com/janlelis/irbtools
+require 'irbtools'
+
+require 'irb/completion'
+require 'irb/ext/save-history'
+
+IRB.conf[:SAVE_HISTORY] = 1000
+IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"
+
View
22 railsrc
@@ -0,0 +1,22 @@
+#!/usr/bin/ruby
+
+# Sources :
+# http://rbjl.net/49-railsrc-rails-console-snippets
+
+def change_log(stream)
+ ActiveRecord::Base.logger = Logger.new(stream)
+ ActiveRecord::Base.clear_active_connections!
+end
+
+def show_log
+ change_log(STDOUT)
+end
+
+def hide_log
+ change_log(nil)
+end
+
+def sql(query)
+ ActiveRecord::Base.connection.select_all(query)
+end
+

0 comments on commit 0c6d566

Please sign in to comment.