Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there any way to activate/deactivate the logging of all input and output on a zsh session?

I am using oh-my-zsh with a customized prompt with colors, etc. and I would like to preserve all of these as possible (so that I can later open the log file in Emacs or less and have them re-parse the ansi color escape codes)

Does zsh provide any functionality to facilitate this type of logging?

Later on, what would be the best way to visualize the log files in Emacs (or some other editor) and have it properly parse all the ansi color escape codes?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

The simplest way to do this would be to use script.

script is a utility which can create a TTY and then launch a program in that TTY. All output from that TTY can be logged to a file as well. It will log the raw data, including ANSI escapes.
When not given a specific command to execute, it will spawn a new shell. You can use this shell as normal, and then just exit the shell when you're done.

For example

script /tmp/mylog

And when you're done, just use CTRL+D or exit to leave the shell.

share|improve this answer

Use screen. To quote from the man page:

   C-a H       (log)         Begins/ends logging of the current window  to
                             the file "screenlog.n".
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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