I am using pdl2 shell, how can I list all my commands history?
Asked
Active
Viewed 413 times
3 Answers
4
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

unpythonic
- 4,020
- 19
- 20
-
1thanks. I forgot about the hist file. I wanted to list the history inside pdl2 to find out what I have done previously before keep going coding and forgot about the posibility of `^z cat...`. Well next time if I really want to see it inside pdl2 I can always do `pdl> print qx{cat ~/.perldl_hist}`. – Pablo Marin-Garcia Jul 10 '11 at 21:29
-
1The problem with this approach is that I want to see the history of my current session without quitting!!. Is that possible? The current session history is only added to .perldl_hist after quitting. – Pablo Marin-Garcia Jul 26 '11 at 00:03
-
1@Pablo - I've updated the answer to get the information from within `pdl`. Please note, you have to have either `Term::ReadLine::Gnu` (preferred) or `Term::ReadLine::Perl` installed. – unpythonic Jul 26 '11 at 01:02
2
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.

chm
- 147
- 1
- 3
-
After developing a computational approach in the `pdl2` shell, you can copy the .perldl_hist file and edit to generate a script/program to do the same. – chm Apr 22 '12 at 04:57