1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

pryで入力履歴(histroy)が上手く機能しない

1
Posted at

事象

pryで入力履歴(histroy)が上手く機能しない。

pryを起動しそのセッションの履歴は表示できるのだが、以前のセッションの履歴が表示されない。

原因

readline

ref: https://github.com/pry/pry/issues/1594#issuecomment-474150732

対応

homebrewreadlineがインストール完了後にrbenvでRubyをインストールする。

RUBY_CONFIGURE_OPTS--with-readline-dir=$(brew --prefix readline)を設定する、という記事も見かけるが、現時点(2019-03-22)では上記未設定の状態でもreadlineがあれば勝手にそちらを利用してくれる様になっている模様。

その他

とりあえず.pry_historyに記載されている履歴を見たい場合

hist --all
  • histコマンド自体は現在のセッションの履歴のみを表示する仕様
  • 以前のセッションを見たい場合は-aまたは--allを付与
  • 履歴を検索したいなら-Gまたは--grepで検索
  • その他オプションはhelp histで確認されたし

とりあえず読み込んでarrow upで呼び出せるようにしたい

Pry.history.load
  • Rubyの再インストールはできない場合やとりあえず暫定でOKなどの場合に
  • pry起動のたびに上記を実行する必要あり
  • .pryrcに上記を記載してもarrow upで呼び出せるようにはならない
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?