Вопрос

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?

Это было полезно?

Решение

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.

Другие советы

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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top