Tips for script (1) command

This article describes tips for script (1) command, which logs your terminal contents.

Do  to read the manual.

Changing the prompt
Probably it's better to change the prompt inside of  command, since you often forget that you're inside of.

It can be done by adding the following code to or :

The output looks like: userFoo ~ $ script Script started, file is typescript log ~ $ echo "script is running" script is running log ~ $ exit exit Script done, file is typescript

Reading the log
To read the log file, by default, with   (1) command, " " option is necessary  in an x terminal. Otherwise it can be unreadable, like this: Script started on Wed Nov 23 21:10:09 2011 ESC ]0;userFoo:~ ^GESC [01;07;31mlog ESC [27;34m ~ $ ESC [00m echo Hello typescript world Hello typescript world ESC ]0;userFoo:~ ^GESC [01;07;31mlog ESC [27;34m ~ $ ESC [00m exit exit

Usually, " " is preferred over , so it's recommended to set your default to.

Theory:
 * By default,  escapes all control codes. This can be unreadable, but safe.
 * doesn't escape at all. If the text contains control codes which your current terminal supports, it can corrupt the output.
 * escapes all control codes except color, bold, etc This is almost safe, and suffices for most cases.

In an x terminal, usually  prints control characters to change the window title before the prompt is printed, and this ruins the output without   option.

Probably you would like a reminder: alias cless="less -r" script { `which script` "$@"; echo "Use 'cless' to view the log" ;}
 * 1) This is "alias which accepts argumets"

Alternative: undefine PROMPT_COMMAND
Since  can be problematic, you may want to undefine   inside of  :

Then, which is safe, must suffice.