Fri 16 Jul 2010
Getting around with GNU Screen
Posted by nola under Linux, open source, Uncategorized
[2] Comments
In past few months, I worked on a project developed entirely on linux. Previously, I mostly did rails development on mac with textmate. I had a brief period of rails and perl where I did vim and screen…oh maybe 4 years ago. Anyways, so I didn’t forget much vim over the years, but I had forgotten how to use screen. I looked some documentation to refresh my memory and this post is mainly notes for me
Most commands start with CTRL-a
I refer to each spawning of a new screen in the current session as a window.
Detach
One things i really like about screen is I can detach it on one computer… then log in somewhere else and reattach. Also handy when you are on a wifi card on the train and you get disconnected. (doh!)
ctrl-a d to detach
then start with -r to reattach: screen -r
Create window
This creates a new terminal window
ctrl-a c
Name that window
Name your window, so its easier to keep organized
ctrl-a A (Yep, ctrl-a then SHIFT-a)
List the windows
See a list of your sessions and their number (this is why you name them) and you can use arrows to select)
ctrl-a “
Navigating Windows
You can flip through the windows in order or specify the number:
ctrl-a p previous window
ctrl-a n, ctrl-a [spacebar] next window
ctrl-a # the number you want to go to (starts at 0).
multiple regions in one
ctrl-a S create a split, creates a new region
ctrl-a TAB switch to next region
ctrl-a c create a terminal session in region
ctrl-a X close the region
ctrl-a C clear, this is like typing clear at the prompt to clear the screen
Closing
To exit a window, simply type exit. To exit and kill all windows do
ctrl-a ctrl-\
Scrolling
Using terminal on mac or linux won’t capture the scroll back…. so you must do it through screen
ctrl-a [ use the arrow key to navigate up
Refresh
ctrl-a l refresh the current display
HELP!!
To see the two (!!) pages of screen commands type:
ctrl-a ?
Command mode
Do you like typing?
ctrl-a : to get to command mode, then you can type commands instead of the ctrl foo jibberish
Need the time?
ctrl-a t ….displays the current system time
Named Screen Sessions
Maybe you are working on two separate projects at once, give each one its own screen session
screen -S ProjectOne
screen -S ProjectTwo
screen -list
then later you can do
screen -r ProjectOne
to reattach it and continue
One thing you can do it make it easier is to add this to your .screenrc
hardstatus alwayslastline "%?%{yk}%-Lw%?%{wb}%n*%f %t%?(%u)%?%?%{yk}%+Lw%?"
It will show the names of the windows you have and highlight the current one. You can see the numbers too so you can do ctrl-a # quickly to jump around.
Anyways, hope this was useful to someone. Let me know any suggestions or anything I can do better!
Sources:
- Unix Screen
- Screen Man Page
