In Rails 4 rails console
I can type history
and it will behave just like the history
command from the bash shell. E.g.:
[25] my_rails_project » history
1: Nomination
2: {:ad => "asdfsdasadf"}
3: Nomination.count
4: Nomination.count.to_sql
5: Nomination.all.class
6: Nomination.all.to_sql
...
Is there a way to search that history, e.g. history | grep Nomination
? How about tail?
Note: When I initially wrote this question I thought the history
command came from Rails itself, but it comes from the pry
gem which I have in my system (my Gemfile specifies the jazz_hands
gem which pulls in pry). Pry does in fact have a grep
feature, e.g. history --grep Nomination
will give me lines 1 and 3-6 above. It also has a tail
feature. These are documented here: https://github.com/pry/pry/wiki/History