Using Screen With Cygwin

Since I’m working in a Windows environment, I use Cygwin quite a lot. Doing that, quite often I need to start a new terminal frame to accomplish a parallel task. But opening a new frame is slow and takes some screen real estate.

A few days ago, I learnt that GNU Screen was (long) available in Cygwin.

Screen allows you (among other things) to start a single Cygwin frame, and to use several different windows in this frame. From the home page:

at any time, you can create new (full-screen) windows with other programs in them (including more shells), kill the current window, view a list of the active windows, turn output logging on and off, copy text between windows, view the scrollback history, switch between windows, etc. All windows run their programs completely independent of each other.

Install and setup

Start Cygwin Setup, screen is available in the Utils section.

Once installed, you can start screen in your .bash_profile or .zprofile.

Make sure your SHELL variable is set so your *shrc file is sourced by interactive shells started by screen.

Then I want the terminal to close when I leave screen, so I use exec to start screen in my .profile :

    exec screen -RD

The -RD options tell screen to save its session when I leave, and to restore it when I come back (see man pages for more details).

Opening Several windows at startup

I often work on two or three fixed directory, so I like to have windows pointing to them when I start a terminal.

In order to to this, you can write a .screen_windows file (for example, but you can find a better name), containing :

    source $HOME/.screenrc

    chdir /usr/local/src
    screen -t sources 1

    screen -t main 0

Then in your .profile, change the screen command to:

    exec screen -RD -c ~/.screen_windows
blog comments powered by Disqus