On Wed, Mar 13, 2024 at 03:26:56PM -0700, Neal Fultz wrote:
> 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=/home/nfultz/projects
>
> SNUM=`screen -Q number`
> SNUM=d${SNUM%% *}
>
> if [ -n "${!SNUM}" ] ; then
> cd "${!SNUM}"
> PROMPT_COMMAND="$PROMPT_COMMAND; sed -i
> 's!$SNUM=.*!$SNUM='\$(pwd)'!' ~/.bashrc"
> fi
>
> fi
>
> This could/should be made much more robust but hopefully that shows that it
> is possible.
Yet another flavor of solution, create set of files ~/.win0,
~/.win1 ... with the content like this:
echo "this is win0!"
cd $(cat ~/.win0.pwd)
export PROMPT_COMMAND="pwd > ~/.win0.pwd"
replace 0 by 1, 2, 3 etc
Create .screenrc:
screen -t win0
screen -t win1
...
at 0 stuff "source ~/.win0^j"
at 1 stuff "source ~/.win1^j"
...
With best regards, Anton