Show a startup banner in `bin/rails console`

ruby/irb#1183 added a startup banner to irb, featuring a small gem logo, version, a rotating tip, and the current directory, shown when IRB is launched.

bin/rails console never goes through IRB.start: Rails::Console sets up prompts/backtrace filtering and calls IRB::Irb.new.run(IRB.conf) directly. So that banner never shows up in a Rails console session.

I’d like to propose a Rails-flavored equivalent for bin/rails console:

  • Reuse IRB’s existing gem-logo art
  • Version line shows Rails <version> - Ruby <version> (<env>)
  • The rotating tip is about the Rails console helpers (app, helper, controller, reload!) instead of IRB’s generic tips.
  • The directory line shows Rails.root instead of raw Dir.pwd.

I have a working patch in railties/lib/rails/commands/console/irb_console.rb plus tests, I would be happy to open a PR if this seems like a good idea.

Here’s how it would appear

(I’m currently working on a version with a Rails logo instead of the irb default)

Alternatively here’s the default rails logo converted:

Big Version:

Small Version:

Hi @gimbaro, I added the IRB banner and I’m glad that you like the idea! I definitely think Rails console could use a nice banner too.

If you want my opinion: the small version looks good, but maybe small tweaking on the logo’s shape would make it even better.

1 Like

Hey @Stan_Lo . I don’t like the banner: I LOVE it ahah. Sadly I’m not very good with ASCII Art, so I’m trying to tweak it with some scripts, starting from the 32x32 favicon. I’ll keep on trying, your opinion is super useful, thanks a lot.

Better Version

I have these two options that I think might be even better:

  ⠀⢀⠀⢡⣶⣿⠟⡛⠢
 ⠠⠀⣰⣿⣿⠁⠄⠀⠀
 ⠶⢠⣿⣿⣿⠰⠆⠀⠀
 ⠶⢸⣿⣿⣿⡄⠰⠆⠀

and

 ⠀⠀⠀⠄⣨⣴⣿⣿⠿⠳⠤
 ⠀⠀⠂⣴⣿⣿⠏⢀⠀⠁⠀
 ⠀⠁⣸⣿⣿⣿⢀⡀⠀⠀⠀
 ⠛⢠⣿⣿⣿⣿⠈⠁⠀⠀⠀
 ⠶⢸⣿⣿⣿⣿⡆⠛⠀⠀⠀

That’s an amazing improvement. I co-authored your change in my fork, thanks a lot :smiley:

I also created the PR here: Show a startup banner in `bin/rails console` by Gimbardo · Pull Request #58393 · rails/rails · GitHub

1 Like