You are not logged in.

#1 2008-08-02 21:36:21

ssjlegendx
Member
Registered: 2008-01-01
Posts: 94
Website

[SOLVED] Open new Screen windows in current directory?

GNOME Terminal has been my preferred terminal application for quite some time; lately, however, I have been using xterm and screen.

In gnome-terminal (and probably in other tabbed terminal apps), opening a new tab (by default) presents the user with a shell (BASH, in my case) opened to the old tab's PWD. If possible, I'd like to have Screen re-create this functionality....

I've found this page on the subject, but my experimentation with Screen windows (which has shown me that new windows are not started as subshells of the window from which they are created) suggests that the described method will not work.

Does anyone know of a way to make Screen emulate this bit of gnome-terminal behavior?

Thanks! smile


Edit:

I just found this information. It seems that issuing the screen command itself (from within Screen) will open a new window in the current directory. As I almost always use the C-a c keybinding to open new windows, I hadn't realized that this works. tongue

I'm going to attempt to create a keybinding to do what I want. I'll post an update with the results.

Last edited by ssjlegendx (2008-08-03 01:38:29)


#!/vim/rocks

Offline

#2 2008-08-03 01:16:15

ssjlegendx
Member
Registered: 2008-01-01
Posts: 94
Website

Re: [SOLVED] Open new Screen windows in current directory?

After looking further into the issue, it seems that the aforementioned keybinding might not be possible. (Explicitly binding C-a c to screen does not alter the normal functioning of that key combination.) Thinking about the situation, it makes sense that Screen cannot know the PWD without getting information from inside the shell (i.e., without being invoked from within the shell).

To overcome this issue, I added the following to my ~/.bashrc:

if [ $TERM == "screen" ]; then
    alias s='screen'
fi

Though this leaves the behavior of C-a c unaltered, using the alias s seems to be a simple way to achieve the functionality I wanted. (It might even prove useful to have the "option" of creating a window in the original directory via C-a c.)


Edit:

I have since modified the above as follows:

if [[ $TERM =~ screen(.linux)? ]]; then
    alias s='screen'
fi

This causes the alias to be set even when running screen from a regular tty (where $TERM is screen.linux).

Last edited by ssjlegendx (2009-04-22 17:41:28)


#!/vim/rocks

Offline

Board footer

Powered by FluxBB