I am using pdl2 shell, how can 开发者_C百科I list all my commands history?
You can find your history in $HOME/.perldl_hist
This may or may not be dependent on having Term::ReadLine::Gnu installed (which I have by default).
If you want access to your history within pdl
, then just use the up arrow key for the previous commands, or type ^R (control-r) then a text that you want to search back for (hitting ^r repeatedly for matches further back).
$ 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
$
EDIT: To find the history from within pdl
, do the following:
$ pdl
pdl> print join "\n", $PERLDL::TERM->GetHistory
The $PERLDL::TERM->GetHistory
returns an array of the current history. It's just a regular array, so you can do whatever you like with it. For example, to find all of your recent histogram operations involving a piddle named mypdl
, you could do:
pdl> print join "\n", grep { /histogram/ && /mypdl/ } $PERLDL::TERM->GetHistory
From the PDL documentation (i.e., 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.
The l
command lists your history if you have a suitable readline
installed.
精彩评论