Thursday, 14 February 2013

♥♥ Couples who code together, stay together ♥♥

Valentines' day is a perfect occasion to snuggle up with your other half and code together.

One problem is how to do this comfortably -- computers are not really designed for two (or more) people sharing.

The solutions below of course work for friends, colleagues or people who have multiple computers around the house and want to have their workspace accessible everywhere.

How to set up a buddy programming environment

There are a number of ways to share a programming environment, but this is the most basic set-up that will work on any PC.

One Computer: 

You need a monitor that you can both see well, and two wireless keyboards.

    1) plug both the keyboard dongles into the computers.
    2) start hacking :)

Two, or more computers, everyone has their own monitor:

1) Decide which computer to run emacs on and start it:
   a) type emacs -nw
   b) type M-x server-start
   c) go out of this window, start a new terminal
   d) type emacsclient -nw --- this is your working window.

2) On the other machine:

   a) ssh into the emacs server machine on the same
   b) type emacsclient -nw --- this is your working window.

At this point, you can both type in the buffer(s) as you please and the cursor and their input will be independent of each other.

This is NOT true of the command line -- whilst you use M- C- etc, you monopolize the cursor and emacs will lock up for a moment for the other person, so you need to communicate.

Watching each other work remotely

Screen is a program which allows you control multiple shells from a single terminal window.  It is a handy tool in many ways for solo or social use.

One feature is that it allows you to show your work as if the other person is looking over your shoulder, no matter where you both are actually located.

Here is a short guide to get you started:

Person starting "screen" session:
    1) type screen
    2) type emacs -nw

Person connecting to "screen" session:
    1) ssh to the server into the account used
    2) type screen -x

You now have a session that the person on the client PC can observe and manipulate as if it was their PC. Note that this shares the cursor, unlike using emacsclient.

Like what you see?  Read the screen manual and find out more!