While modern desktop environments usually start all the applications which were open in the previous session and some terminal emulators may even open as many tabs as before, I've never seen a terminal emulator which
- opens a shell in that directory in which its previous shell was when the terminal emulator was closed, and
- shows the same output as before.
Technically both things should be possible:
- The current working directory of the shell can be found via the
/proc
file system. - If the terminal emulator saves all text (including ANSI sequences) shown before its closed, it could restore that state and then start the shell in the directory it last was. If the terminal emulator also saves the state of the shell's history file at the state after the terminal has been closed, it could also make the shell load that specific history file on next startup.
Sure, there are other things like having the exit code of the previous command or the previous working directory available in a variable, but my main motivation here is to be able to continue working on the results of my previous command (e.g. a compiler run which resulted in errors or a package build which had some warnings) despite I had to exit my whole X session or even reboot the machine — without manually capturing that output which will remind me or help me to continue the work I was about to do.
So I wonder: Is there is already an terminal emulator for X which can do these things?
The case surely more difficult if other, especially text-mode applications were running in such a terminal, maybe called from within the shell. Reproducing their state is not done with just a directory name and history file.
But then again, there exist (more or less working) tools to freeze and thaw whole processes…
screen
?screen
to accomplish most of your requirements, except the 'repainting'.