Created
October 8, 2010 07:12
-
-
Save iiska/616461 to your computer and use it in GitHub Desktop.
Command history, tab completion and Rails SQL logs for script/console
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
# -*- mode: ruby -*- | |
# TAB completion for irb | |
require 'irb/completion' | |
ARGV.concat [ "--readline", "--prompt-mode", "simple" ] | |
# Save command history to be used between multiple sessions | |
require 'irb/ext/save-history' | |
IRB.conf[:SAVE_HISTORY] = 100 | |
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history" | |
# Output Rails logs to stdout when using script/console | |
script_console_running = ENV.include?('RAILS_ENV') && IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers') | |
rails_running = ENV.include?('RAILS_ENV') && !(IRB.conf[:LOAD_MODULES] && IRB.conf[:LOAD_MODULES].include?('console_with_helpers')) | |
irb_standalone_running = !script_console_running && !rails_running | |
if script_console_running | |
require 'logger' | |
Object.const_set(:RAILS_DEFAULT_LOGGER, Logger.new(STDOUT)) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment