Message Boards Message Boards

0
|
52 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Creating a listing of the commands I typed while running Wolfram in a terminal window

Posted 17 hours ago

I would like to have all the Mathematica commands entered during a terminal session, written exactly as typed to a text file. No Box wrappers, no HoldForm wrappers, just what I typed. Each on a separate line. And the commands should not be evaluated again when I "write" them to a file.

The idea is that I'm working, I type journalFile@"journal1.txt", and the file is open, written, and closed. I work some more and again type journalFile@"journal2.txt" and a newer, slightly larger file is created. So I would like a function journalFile.

Have experimented with $Echo, HoldForm, In and various combinations without luck. I can get close, with HoldForm wrapped around things, but don't want that.

POSTED BY: Paul Nielan

If I understand your request correctly this should do the trick

journalFile[file_] := With[
    {
        inputs = Replace[
            DownValues @ In,
            HoldPattern[RuleDelayed[_, input_]] :> ToString[Unevaluated[input], InputForm],
            {1}
        ]
    },
    Export[file, inputs, "Lines"]
]
POSTED BY: Jason Biggs
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract