Note that $WINDOW is the number when the process is created, vs `screen -Q` is at runtime - if/when you renumber windows they will no longer match. Maybe that's a bug you can live with, though.
Hi, thanks for this hint, I update your code
# Screen only
if [ -n "$STY" ] ; then
source ~/.screendb
SNUM=d$WINDOW
if [ -n "${!SNUM}" ] ; then
cd "${!SNUM}"
PROMPT_COMMAND="$PROMPT_COMMAND; sed -i 's!$SNUM=.*!$SNUM='\$(pwd)'!' ~/.screendb"
fi
fi
the "WINDOW" variable is already do the `screen -Q number` thing and I use the
external ".screendb" for storage.
d0=/home/myusr/prj/tool
d1=/home/myusr
d2=/tmp
d3=.
d4=.
d5=.
d5=.
d7=.
d8=.
d9=.
On 13.03.24 23:26, Neal Fultz wrote:
> # 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