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

Is there anything like that? Or should I try and code this with preexec() and all that?

migrated from stackoverflow.com Sep 25 '12 at 13:42

This question came from our site for professional and enthusiast programmers.

  • A couple questions. Do you want to be able to distinguish between information provided in stdin, from stdout and stderr? 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? – Horn OK Please Sep 25 '12 at 13:48
  • yep. just like saving what I see in the terminal. – pvinis Sep 26 '12 at 23:53
up vote 1 down vote accepted

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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