How can I make GNU Screen start a new window at the CURRENT working directory?

Viewed 24161

By default, when you create a new window in GNU Screen, it will start in the directory where Screen is invoked. I want to start a new window in GNU Screen at the current working directory of the window I'm currently in. How can I do that?

8 Answers

I have a nearly perfect solution for Bash. :)

  1. If you never use password to set a lockscreen password, just add this to file $HOME/.bash_profile:

     export PROMPT_COMMAND='screen -p $WINDOW -X chdir "$PWD"'
    
  2. Do you need a password? With this:

     # The digest of password "abc" is ID1wIq4l2t7s6
     export PROMPT_COMMAND='screen -p $WINDOW -X eval "password none" "chdir \"$PWD\"" "idle 0 password ID1wIq4l2t7s6"'
    

I just hope the developers of Screen add the environment variable PWD as soon as possible.

Related