3

pdl2 シェルを使用していますが、すべてのコマンド履歴を一覧表示するにはどうすればよいですか?

4

2 に答える 2

3

履歴は $HOME/.perldl_hist にあります

これは、Term::ReadLine::Gnu がインストールされているかどうかに依存する場合とそうでない場合があります (デフォルトでインストールされています)。

内で履歴にアクセスしたい場合pdlは、前のコマンドに上矢印キーを使用するか、^R (control-r) を入力してから検索したいテキストを入力します (^r を繰り返し押して、さらに前の一致を探します)。 .

$ pdl
perlDL shell v1.354
...blah blah blah...
pdl> print 1+1
2
pdl> print 2+2
4
pdl> quit

$ cat ~/.perldl_hist 
print 1+1
print 2+2
$ 

編集: から履歴を見つけるpdlには、次の手順を実行します。

$ pdl
pdl> print join "\n", $PERLDL::TERM->GetHistory

$PERLDL::TERM->GetHistoryは、現在の履歴の配列を返します。これは単なる通常の配列なので、好きなことを行うことができます。たとえば、 という名前のピドルを含む最近のヒストグラム操作をすべて見つけるには、次のmypdlようにします。

pdl> print join "\n", grep { /histogram/ && /mypdl/ } $PERLDL::TERM->GetHistory
于 2011-07-10T07:22:21.960 に答える
1

PDL ドキュメント (つまり、pdldoc perldl) から:

History mechanism
  If you have the perl modules ReadLines and ReadKeys installed, then
  perldl supports a history and line-editing mechanism using editing keys
  similar to emacs. The last 500 commands are always stored in the file
  .perldl_hist in your home directory between sessions. Set
  $PERLDL::HISTFILESIZE to change the number of lines saved. The command
  "l [number]" shows you the last "number" commands you typed where
  "number" defaults to 20.
于 2012-04-22T04:54:53.877 に答える