Re: last recently *used* screen?
Jürgen Weigert <[email protected]> Wed, 7 May 2025 12:42:12 +0200
| Newsgroups | gmane.comp.gnu.screen.user |
|---|---|
| Message-ID | <CAMPiZwAtCcT2tQbLfm+yK4rkqri0rU0LeQWGMqxL_owUyPpGgA@mail.gmail.com> |
--000000000000694c470634896357 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I believe the information which session was used last is already present. There should be no need for a .screen.lastsession file. Here is a bash script, that looks at the mtime of each socket and reattaches to the last modified one: https://gist.github.com/jnweiger/20e54876839fb81e14e50b9eaf9d3915 On Wed, May 7, 2025 at 11:27=E2=80=AFAM Vegard Svanberg <[email protected]= > wrote: > * Thorsten Glaser <[email protected]> [2025-05-05 23:08]: > > > how can I find out the last recently used screen, to help a friend=E2= =80=A6 > > I don't think screen has the tmux equivalent of hooks... > > I haven't thought this through, but two alternatives spring to mind: > > A) Add this feature to screen > > Shouldn't be too hard I think... just something which writes the session > name to a (configurable) file somewhere upon creating, attaching and > detaching. > > B) A heartbeat script > > Create a new (hidden) screen window and run something like: > > while true ; sleep 5 ; echo "$STY" > "$HOME/.screen.lastsession" > > Obviously this would still run when the screen is detached, so you'd > have to add some logic to detect that and pause the update. > > You could possible add something in .screenrc to spawn this > automatically. > > Personally, I think I'd patch screen and contribute the code. > > Warmly, > > Vegard > > -- > Vegard Svanberg <[email protected]> [*Takapa@IRC (EFnet)] > > > --000000000000694c470634896357 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><div>I believe the information which sess= ion was used last is already present. <br></div>There should be no need for= a .screen.lastsession file.<br></div><div>Here is a bash script, that look= s at the mtime of each socket and reattaches to the last modified one:<br><= /div><div><br></div><div><a href=3D"https://gist.github.com/jnweiger/20e548= 76839fb81e14e50b9eaf9d3915">https://gist.github.com/jnweiger/20e54876839fb8= 1e14e50b9eaf9d3915</a></div><div><br></div><br><div class=3D"gmail_quote gm= ail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Wed, May 7, 2= 025 at 11:27=E2=80=AFAM Vegard Svanberg <<a href=3D"mailto:vegard@svanbe= rg.no">[email protected]</a>> wrote:<br></div><blockquote class=3D"gmai= l_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,20= 4,204);padding-left:1ex">* Thorsten Glaser <<a href=3D"mailto:tg@debian.= org" target=3D"_blank">[email protected]</a>> [2025-05-05 23:08]:<br> <br> > how can I find out the last recently used screen, to help a friend=E2= =80=A6<br> <br> I don't think screen has the tmux equivalent of hooks...<br> <br> I haven't thought this through, but two alternatives spring to mind:<br= > <br> A) Add this feature to screen<br> <br> Shouldn't be too hard I think... just something which writes the sessio= n<br> name to a (configurable) file somewhere upon creating, attaching and<br> detaching.<br> <br> B) A heartbeat script<br> <br> Create a new (hidden) screen window and run something like:<br> <br> while true ; sleep 5 ; echo "$STY" > "$HOME/.screen.lasts= ession"<br> <br> Obviously this would still run when the screen is detached, so you'd<br= > have to add some logic to detect that and pause the update. <br> <br> You could possible add something in .screenrc to spawn this<br> automatically.<br> <br> Personally, I think I'd patch screen and contribute the code.<br> <br> Warmly,<br> <br> Vegard<br> <br> -- <br> Vegard Svanberg <<a href=3D"mailto:[email protected]" target=3D"_blank"= >[email protected]</a>> [*Takapa@IRC (EFnet)]<br> <br> <br> </blockquote></div></div> --000000000000694c470634896357--