July 14th, 2005

How to reattach to GNU screen sessions in windows (cygwin)

I use a Windows version of the GNU Screen window manager/terminal multiplexer every day, and wanted to share a trick that I’ve learned over time. A lot of people have trouble with reattaching to existing screen sessions in the windows/cygwin version. You can probably accomplish this different ways, but this is what I have been doing every day at work for at least 9 months now:

  1. open first bash shell window
  2. run: screen
  3. open another bash shell window
  4. run: screen -x
    NOTE: this window will probably not reattach, at least it doesn’t for me. if it does, these instructions are useless for you.
  5. close second bash window (opened in step 3).
  6. open another bash shell window
  7. run: screen -x

At this point, both bash windows are now connected to the same screen session.

Variations on this may work.. I’ve done this in a lot of different conditions, including of course ssh-ing into a box and attaching to the existing screen session, and also using ssh-agent just right to avoid having to type passwords all day long. More on that later, but for now, I just wanted to get this basic information out there.

The main idea is that the first attempt to attach to an existing screen session will fail, but if you try again in a new window it should work.