VT100 terminals have a relatively simple way to save terminal contents with escape codes to a file using Meta-p:
XTerm.VT100.printAttributes: 2
XTerm.VT100.printerCommand: cat - > file
XTerm.VT100.translations: #override Meta <KeyPress> P: print() \n
I've looked around quite a bit, and can't find a solution for this to work in the default GNOME Terminal + XTerm + Bash.
I do not want just an image with the contents of the window.
It looks like GNOME Terminal might eventually get a fix for this, but there's no information about which version it will be included in, and it's been almost three years since the last update...
Unfortunately, l0b0 the answer out of the box is: This is not possible.
There are two ways you can attempt to rectify this, by running script at all times on your terminal and logging all output. Open up gnome-terminal, go to Edit->Profile Preferences, then the tab Title and Command and for your custom command use this:
Make sure 'sessionlogs' exists under $HOME.
The other way has been removed and added as a second answer on this question.
Unfortunately, l0b0 the answer out of the box is: This is not possible.
In my other answer, I listed how to use script to do this, though there are some differences as you noted. The other way is to compile the source or use an unstable version.
Gnome Terminal Source Tarball
The version in Raring is 3.6.1, so you can look at this source. Inside of Terminal-window.c on line 115:
Options:
Hope this helps.
You can run your shells via script(1) to get all input and output of the terminal stored in a file, including terminal escapes.
There's a package that's called screen - a terminal multiplexor with VT100/ANSI terminal emulation.
According to the manpage of screen on the Ubuntu Manuals website , screen claims to be
and when running screen:
I tried in the GNOME Terminal, running
screen
and typing Ctrl ahThis is the output of my hardcopy.1 file when opened in Gedit:
You can find screen is in the raring/main software repository of Ubuntu 13.04.
It's not installed by default.
Hm, this will not copy the escape codes, but just to grab the text, you can go to menu Edit -> Select All, then press CtrlShiftC and either (i) paste the clipboard to an editor or (ii) type
cat > filename
and press CtrlShiftV.man history
look for history expansion for escaped characters. I believehistory
can do what youre asking.