I would like to keep not just history of my commands, but the output as well.
If I type ls
then it should append to a file
~/Desktop% ls
test.jpg
file.txt
whatever.pdf
Is there anything like that? Or should I try and code this with preexec()
and all that?
2 Answers
I used a spyshell. A shell that just runs script, and that opens zsh. I cannot find the link, so I made a gist. Here it is: https://gist.github.com/3791646
Have a look at the script
utility, which is pretty ancient and should come preinstalled on most UNIX flavours or Linux distros.
Entering script session.log
at the shell prompt will drop you into a subshell while recording everything you do — both input and output — to the plaintext file session.log
. Typing ^D will exist the subshell (as usual).
See the script(1)
man page for more details.
stdin
, fromstdout
andstderr
? Or do you literally just want a log of the text exactly as it is displayed in the virtual terminal, with no inherent ability to distinguish between data output by a program on stdout/stderr and data keyed into the terminal via the keyboard or other stdin device?