Pregunta

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?

¿Fue útil?

Solución

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.

Otros consejos

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
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top