screen-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Opening a new window, and cd to the same directory as the current window


From: address@hidden
Subject: Opening a new window, and cd to the same directory as the current window, no matter what I'm doing
Date: Tue, 30 Oct 2007 14:15:44 +0100
User-agent: Mozilla-Thunderbird 2.0.0.4 (X11/20070828)

Hello,

(by error, I've also sent this to screen-devel, and I apologize for it)

Hello,

As the title says i'd like to find a way to open a new window and change its CWD to the same dir as the curent window (well the 'other' one once the new window is created)

So far, this is what I came up with:

=> I can issue:
   screen -X eval screen "stuff 'cd $PWD^M^L'" other

on the command prompt, and it works.
However, this obviously doesn't work if, on the current window, I'm on a remote 
box (via ssh...)

and as a minor problem, I can't find a way to bind this to a key:
 bind N stuff 'screen -X eval screen "stuff \'cd $PWD^M^L\'" other'

I got:
: Missing " quote.

(I could make an alias, but I'd have prefered a 'keystroke')





Anyway, my point would be to have something like this working working no matter 
what i'm doing on the current window.

So.. a few more questions:

1) Is there a way for screen to know an environment variable value in one given 
window?
if this is possible I could use screen to set this var: WOLDPWD (window OLDPWD) before the new window is created, and then in my ~/.bashrc, I can check if this var is defined, and change directory if it is.

2) if answer to 1) is no, then is there a way for screen to know which tty is 
'used/attached ?' on current window?
Again, if is possible, then I could use screen to store this value in a variable, before the new window is created, and then in my ~/.bashrc, I can find the process 'owning?' this tty, and find its CWD...

3) How is the current window number stored in screen? I mean, is there a command, a register or something, that would tell me the current window number? Then I could store it in a variable before creating the new window...

and... since on every window, the variable $WINDOW is defined (at window creation, I know, but I don't change the window number), in my ~/.bashrc, I could find back the process with $WINDOW = current window, and then find its CWD



Ok that's a lot of questions I know, but this is the last bit I'm really 
missing in my screen conf :)

Thanks in advance :)

samlt




reply via email to

[Prev in Thread] Current Thread [Next in Thread]