I work in Maxima a lot (start it on the terminal with "rlwrap .../maxima" and sometimes I want to save a few (several) screens worth (scrolling) of calculations.

I realize I can use xmaxima, a variant that can then save it to a text file - that works. But I also sometimes use scipy/python in the terminal, or even others.

In general, is there a way to save several screens of interactive program input/output from the bash terminal to a file (possibly preserving 'word art', or 2D display)?

I use terminator, though not sure it matters. Also, sometimes I work on a debian system and other times on Linux Mint.


This is what the script tool is for. It will save an entire terminal session - inputs and outputs:

$ script sessionlog.txt
[ do stuff ]
$ exit
$ ls sessionlog.txt
  • Wow, super cool! I hadn't heard of it before so thanks, but I am getting lots of weird symbols in the output file. Unfortunately I couldn't even get something like `org' from emacs to work either. – nate Dec 15 '17 at 21:22
  • Those strange characters in the output file are what move the cursor around and change character cell colours. If you cat the file you'll see exactly what you saw when you made the recording. As it's a complete record of everything that happens, you'll see everything that transpired, including mistakes you made, backspaced over, and corrected. – DopeGhoti Dec 15 '17 at 22:47
  • I see... yeah, an editor does show those symbols, while cat' doesn't.... I tried cat scriptOut.txt > scriptOut2.txt' but it is not any cleaner. I also looked at the man pages but no idea of how to not caputre those symbols... – nate Dec 15 '17 at 23:26
  • If you remove those symbols, you are removing the data required to accurately recreate your terminal session. – DopeGhoti Dec 18 '17 at 16:42
  • maybe my question wasn't clear... maxima, python, reduce, and other similar programs (I don't know about all), wouldn't need these symbols at all. I was thinking of something like org for emacs, or saving a session in xiki, or... but this is cool tool for sure. – nate Dec 18 '17 at 16:57

Especially since you're already using rlwrap:

rlwrap has a --logfile (shorter:-l) option that will save the entire session (all edited input lines, and all output from the rlwrapped command) to a file:

rlwrap --logfile log.txt ../maxima

script is brilliant, but will also save all your typos and their corrections, which may be more than you need. rlwrap doesn't record anything until you enter a line, and then remembers only that line (and any command output that comes after it)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.