Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dtach eats output of prev. commands #6

Open
safinaskar opened this issue Dec 19, 2016 · 5 comments
Open

dtach eats output of prev. commands #6

safinaskar opened this issue Dec 19, 2016 · 5 comments

Comments

@safinaskar
Copy link

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.

@rdebath
Copy link

rdebath commented Dec 19, 2016

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.

@ackerleytng
Copy link

@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.

@safinaskar
Copy link
Author

@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.)

@safinaskar
Copy link
Author

safinaskar commented Apr 22, 2023

(I just did this dtach -c /tmp/sock -r winch bash test with dtach 0.9)

@Atry
Copy link

Atry commented Aug 27, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants