Suppose that I am running
screen on a remote server with four open screens. Is there a quick way to
cd all the screens to the working directory of the currently-open screen?
Here is a work-around: on one tab, record the CWD into a temp file, on the other tabs, cd to the just-saved dir. I would put these two aliases to my .bashrc or .bash_profile:
alias ds='pwd > /tmp/cwd' alias dr='cd "$(</tmp/cwd)"'
the ds (dir save) command marks the CWD, and the dr (dir recall) command cd to it. You can do something similar for C-shell.
The answer is basically "No". Each of the programs running in each screen are separate processes with their own working directory. It is not possible to change the working directory of another process. A process can only change its own working directory.
That being said, the workaround that Hai Vu pointed you at will work. It basically stores the working directory in a file, then you have to go to each other window and run a different command that reads that file in and sets the current working directory based on it.
There might be some ugly trick you could pull with
PROMPT_COMMAND to make
bash automatically change the working directory if the contents of the file have changed. That wouldn't take effect until you'd run at least one command though.
Perhaps if you gave the reason you wanted this behavior a solution to that problem could be given instead.