0

When I'm using the rails console I like having a clear! command along side the reload! command, so every time I launch the rails console I write

def clear!
   system('clear')
end

When I repeat behavior in my bash shell I add it to my ~/.bashrc file. Is there a similar way for me to do this for my rails console?

backus
  • 4,076
  • 5
  • 28
  • 30
  • Just realized that `control`+`l` clears irb/rails console too, so don't use the redundant clear function in my example – backus Jul 18 '13 at 11:21

2 Answers2

2

Create a file in your home directory named ~/.irbrc. Inside, define any functions or settings you want to be applied to your irb.

Here's an example that explains what I mean.

sameetandpotatoes
  • 1,220
  • 3
  • 17
  • 35
0

You can do this with Pry if you use that instead of irb. You can configure custom commands in a ~/.pryrc

Pry.config.commands.command "clear!", "Clears the display" do |*args|
  system("clear")
end
deefour
  • 34,974
  • 7
  • 97
  • 90