Saturday, June 20, 2009

Remote Pair Programming using SSH, Screen, Vim and Skype



Screen Cheat Sheet


Basic commands

  • screen -S test_session -> start screen session with session name
  • ctrl+a, d -> detach from a session
  • screen -r test_session -> reattach to existing session
  • ctrl+a, c -> create new window
  • ctrl+a, A -> rename a window
  • ctrl+a, w -> list open windows
  • ctrl+a, space -> switch to next window

Commands for pair programming

  • screen -S test_session -> on the server, start screen session
  • ctrl+a, :multiuser on -> allow multiuser session
  • ctrl+a, :acladd guest -> allow guest account to connect
  • ssh guest@my_server_ip -> on the client, connect remotely to the server
  • screen -x oren/test_session -> ...and attach to existing screen session
  • ctrl+a, F -> fit screen to my terminal size
  • aclchg guest -w "#" ->make guest read only (he will still be able to watch you)

Screen Configuration File (.screenrc)

# enable multisession
multiuser on

#allow 2 accounts to use multisession
acladd oren,guest

#make guest read only (not working for me, I do it inside screen instead)
aclchg guest -w "#"

#show the windows line at the bottom of the screen
hardstatus string "%1`"
hardstatus alwayslastline
hardstatus string '%{= kG}[%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'

# tell screen to open those windows automatically
screen -t terminal 0
screen -t vim 1
screen -t server 2
screen -t mySql 3

#map F7/F8 to move between windows
bindkey -k k7 prev
bindkey -k k8 next

1 comment:

Ng Tze Yang said...

Tks for sharing, if u place the multiuser, acladd & aclchg commands after the 'screen -t' lines, that should fix the problem of limiting the guest's rights. At least this works for me :]