On Wed, 22 Jun 2011, Tomasz Muras wrote:
Hello,
I'm wondering if something like this would be possible:
I would like to quickly switch to the same current working directory
as in another screen window. Would it be possible to read cwd of
another window?
It takes a bit of screen scripting, but this took me about 5 minutes to throw
together:
-- begin chscdir --
#!/bin/sh
screen -X msgwait 0
screen -X at "$1" stuff ""
screen -X at "$1" stuff "pwd > $TMPDIR/buffer ^M"
screen -X readbuf
screen -X stuff "cd "
screen -X paste .
screen -X removebuf
screen -X msgwait 4
-- end chscdir --
I redefine the buffer file in my .screenrc to be in $TMPDIR/buffer
rather than the default of /tmp/screen-exchange. Adjust this as
necessary.
This just requires that you know the screen number of the screen you
want to match, and that it be at a shell prompt. It can't magically
know the dir if that other screen is in a vi session or something.
The control chars above need to be entered with a ^V first (^V^U) so
that they get inserted rather than evaluated.
To use:
In screen 4, you're sitting in some deep directory, say something like:
/usr/local/src/mynewproj/src/modules/funstuff
And in screen 8, you're in your home directory, but want to be in the
same dir as screen 4.
While sitting in screen 8, type:
chscdir 4
And the command 'cd /usr/local/src/mynewproj/src/modules/funstuff'
should show up on your current screen, and you should now be in that
directory.
If you were to pop back over to screen 4, you would see the pwd command
that was executed.
--
Michael Parson
mpar...@bl.org
Austin, TX
KF5LGQ
_______________________________________________
screen-users mailing list
screen-users@gnu.org
https://lists.gnu.org/mailman/listinfo/screen-users