Have you tried screen? AFAIK it's similar to tmux, but tmux has more bells and whistles, which it sounds like you want to avoid. I use it sometimes to start long running rsync sessions on a server and then periodically SSH in and check it. It does break scrolling though, but I don't know if there's some option to make it behave more like a normal terminal.
post
You have a bunch of answers including one you chose, but you can always rebind the tmux key to something compatible with your terminals search and use [key] - d to disconnect from your tmux session then invoke it with tmux attach-session to get back into your session.
on attach it should clear the screen, print the stdout buffer it accumulated and give me stdin prompt, that’s it
The last part of the above, disconnecting from tmux and reattaching would do what you described. That may be useful if you need to work with tmux.
Maybe I'm misunderstanding what your requirements are, but screen may be what you need https://www.man7.org/linux/man-pages/man1/screen.1.html
You might also be able to background the process:
https://linuxize.com/post/how-to-run-linux-commands-in-background/
Might not be exactly what you want but I sometimes use mosh for this reason, I can start a task in the mosh terminal and then minimize or sleep, or even hibernate the machine and I will be able to come back to the same session later. (It also continues running if the connection is lost, and will reconnect when able)
You could also create a user systemd service. It’s just a few line config you drop into the correct place in your home directory.
Run the background stuff as a daemon, and then write an interface to take stdin/stdout and interact with that daemon.
all 10 comments