Re: screen session remember
Neal Fultz <[email protected]> Wed, 13 Mar 2024 15:26:56 -0700
| Newsgroups | gmane.comp.gnu.screen.user |
|---|---|
| Message-ID | <CAL9B2vdVxVZ3S1VdrVp_U=+zKMmgSDSjHDthAsx90YAKxRBYWg@mail.gmail.com> |
--000000000000efeb2b061392470b
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
I would probably tackle this on the shell side rather than in .screenrc.
For example, in ~/.bashrc, on startup, we can check what the number of the
screen is. And use PROMPT_COMMAND to update to the most recent eg using
sed.
# Screen only
if [ -n "$STY" ] ; then
d1=3D/home/nfultz/projects
SNUM=3D`screen -Q number`
SNUM=3Dd${SNUM%% *}
if [ -n "${!SNUM}" ] ; then
cd "${!SNUM}"
PROMPT_COMMAND=3D"$PROMPT_COMMAND; sed -i
's!$SNUM=3D.*!$SNUM=3D'\$(pwd)'!' ~/.bashrc"
fi
fi
This could/should be made much more robust but hopefully that shows that it
is possible.
-Neal Fultz
On Wed, Mar 13, 2024 at 2:12=E2=80=AFPM aotto <[email protected]> wrote=
:
> Thanks for the answer - this hint I already use.
>
> =E2=86=92 but I would like to have a "replacement" which is always "up-to=
-time"
>
> On 13.03.24 22:01, Anton Sharonov wrote:
> > On Wed, Mar 13, 2024 at 08:46:30PM +0100, aotto wrote:
> >> I have a =E2=80=9Cscreen session=E2=80=9D with 10 screens and after
> >> rebooting I want each screen (0-9) to start in the same
> >> directory in which it was closed.
> > Maybe not exactly what you are asking for, but you can
> > hardcode your shells to curtain path on start using something
> > like this in your ~/.screenrc:
> >
> >
> > screen -t 0_vim
> > screen -t 1_vim_doc
> > ... continue with your number of shells ...
> > at 0 stuff "cd ~/.vim^j"
> > at 1 stuff "cd ~/.vim/doc^j"
> > ... etc ...
> >
> >
> > With best regards, Anton
>
>
>
>
--000000000000efeb2b061392470b
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I would probably tackle this on the shell side rather than=
in .screenrc.<div><br></div><div>=C2=A0For example, in ~/.bashrc, on start=
up, we can check what the number of the screen is. And use PROMPT_COMMAND t=
o update to the most recent eg using sed.=C2=A0<div><br></div><div># Screen=
only<br>if [ -n "$STY" ] ; then<br>=C2=A0=C2=A0<br>=C2=A0 =C2=A0=
d1=3D/home/nfultz/projects<br><br>=C2=A0 =C2=A0 SNUM=3D`screen -Q number`<=
br>=C2=A0 =C2=A0 SNUM=3Dd${SNUM%% *}<br><br>=C2=A0 =C2=A0 if [ -n "${!=
SNUM}" ] ; then<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 cd "${!SNUM}"=
<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 PROMPT_COMMAND=3D"$PROMPT_COMMAND; sed=
-i 's!$SNUM=3D.*!$SNUM=3D'\$(pwd)'!' ~/.bashrc"<br>=
=C2=A0 =C2=A0 fi<br><br>fi<br></div></div><div><br></div><div>This could/sh=
ould be made much more robust but hopefully that shows that it is possible.=
</div><div><br></div><div>-Neal Fultz</div><div><br></div><div><br></div><d=
iv><br></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D=
"gmail_attr">On Wed, Mar 13, 2024 at 2:12=E2=80=AFPM aotto <<a href=3D"m=
ailto:[email protected]">[email protected]</a>> wrote:<br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">Thanks for the answer - t=
his hint I already use.<br>
<br>
=E2=86=92 but I would like to have a "replacement" which is alway=
s "up-to-time"<br>
<br>
On 13.03.24 22:01, Anton Sharonov wrote:<br>
> On Wed, Mar 13, 2024 at 08:46:30PM +0100, aotto wrote:<br>
>> I have a =E2=80=9Cscreen session=E2=80=9D with 10 screens and afte=
r<br>
>> rebooting I want each screen (0-9) to start in the same<br>
>> directory in which it was closed.<br>
> Maybe not exactly what you are asking for, but you can<br>
> hardcode your shells to curtain path on start using something<br>
> like this in your ~/.screenrc:<br>
><br>
><br>
> screen -t 0_vim<br>
> screen -t 1_vim_doc<br>
> ... continue with your number of shells ...<br>
> at 0 stuff "cd ~/.vim^j"<br>
> at 1 stuff "cd ~/.vim/doc^j"<br>
> ... etc ...<br>
><br>
><br>
> With best regards, Anton<br>
<br>
<br>
<br>
</blockquote></div>
--000000000000efeb2b061392470b--