Use retty in screen to attach already running applications
Ever left some longer running script/process/something at home and than wished you could control it via ssh and it wasn’t started in a screen session? Fear not, retty is here to rescue! To demonstrate this:
$ irssi # switch to new terminal $ screen -S irssi $ retty `pgrep irssi` /redraw
To explain what is going on here, first we start a normal application in one terminal, this could be any other thing, like a script doing heavyweight processing. In the new terminal we start the screen session, this is an optional step, it allows us to be able to later on detach/reattach the session at will. Inside the screen session we hijack the irssi PID. The last step, /redraw is only necessary because we are dealing with complex ncurses stuff which does weird stuff when it’s in operation . For the same reason you have to run “reset” in the first terminal if you want to keep using it normally. This by itself isn’t really useful, however you can use the exact same procedure to reattach something via ssh.







