Script/console custom prompt

Hi,

I’m not able to use a custom prompt with script/console. I can’t seem to
change the prompt once I’m inside irb. I can only change by passing in
the --prompt arg to irb. However, it seems script/console has the simple
prompt hardcoded in the script. I hacked the script a little and it
seems to work, but I’m sure there is a more elegant way to do it.
Anyway:

irb = RUBY_PLATFORM =~ /mswin32/ ? ‘irb.bat’ : ‘irb’

require ‘optparse’
options = { :sandbox => false, :irb => irb, :prompt => ‘simple’ }
OptionParser.new do |opt|
opt.banner = “Usage: console [environment] [options]”
opt.on(’-s’, ‘–sandbox’, ‘Rollback database modifications on exit.’)
{ |options[:sandbox]| }
opt.on("–irb=[#{irb}]", ‘Invoke a different irb.’) { |options[:irb]|
}
opt.on("–prompt=[]", ‘Use a different prompt for irb.’) {
|options[:prompt]| }
opt.parse!(ARGV)
end

libs = " -r irb/completion"
libs << " -r #{RAILS_ROOT}/config/environment"
libs << " -r console_sandbox" if options[:sandbox]

ENV[‘RAILS_ENV’] = ARGV.first || ‘development’
if options[:sandbox]
puts “Loading #{ENV[‘RAILS_ENV’]} environment in sandbox.”
puts “Any modifications you make will be rolled back on exit.”
else
puts “Loading #{ENV[‘RAILS_ENV’]} environment.”
end
exec “#{options[:irb]} #{libs} --prompt-mode #{options[:prompt]}”