Open safinaskar opened 7 years ago
Dtach doesn't really understand the terminal emulator that you're using. It doesn't filter the output from the host at all.
Because of this the 'alternate screen' that 'screen' and 'tmux' can use to preserve the previous state of the terminal is not available; it may be used by the program that you run using dtach.
Now IF your problem is that you're running a text editor under dtach and the text editor would normally use the alternate screen but the screen is getting cleared with dtach. I may have a solution for you.
The second item in my PR #5 will let you disable this clear screen.
@safinaskar Could the behavior you're observing be because dtach tries to send Ctrl-L after reconnecting? I believe Ctrl-L "clears" the previous commands on the shell.
Try and see if adding -r winch
for dtach makes a difference. In my experience, the previous activity is not cleared away by changing the redraw method with -r
.
@ackerleytng , I tried dtach -c /tmp/sock -r winch bash
and I don't see any difference. (Also, I lost interest in dtach anyway, and I don't remember why I needed it in the first place, so you may close this bug.)
(I just did this dtach -c /tmp/sock -r winch bash
test with dtach 0.9)
script
can record the output, so combining dtach
with script
would solve the problem.
To start a session and record output:
dtach -c /tmp/my-session.dtach script --flush /tmp/my-session.typescript
To restore the output and attach to the session:
sleep 0.1 && cat /tmp/my-session.typescript & dtach -a /tmp/my-session.dtach -r none
The sleep 0.1
part is tricky. Without it, cat
would print the output but then dtach
would clear it. Adding sleep 0.1
lets cat
be executed after starting dtach
.
Type some commands to terminal. Then start dtach. Then exit from dtach. You will see all previous activity (i. e. before starting dtach) is disappeared (as opposed to screen and tmux).
$ dtach --version dtach - version 0.9, compiled on May 21 2016 at 08:04:42.