Monday, February 26, 2007

Screen Command Usage

Create a new Screen session
screen # creates a default session
screen -S name # creates a session with a name

# Screen has two similar concepts: screens and window sessions.
# screens are seperate processes that show up when doing
# a "screen -ls" listing. Windows are "sub-screens" of a given
# screen process used for split screen modes and such.

Rename an already created window
CTRL-a A # then provide name

Rename a screen (interactively)
CTRL-a :sessionname newsessionname

Rename a screen (without attaching)
screen -X sessionname newsessionname

Detach from a screen session
screen -d # detach from a command prompt
Ctrl-a d # detach from anywhere in the session

List screen sessions

screen -ls

Reattach to a screen session
screen -r # attaches to default session
screen -r name # attaches to specific session (unique string in the name)

Toggle between several attached windows
Ctrl-a Ctrl-a

Attach to an already attached screen (mirror)
screen -x # attaches to default session
screen -x name # attaches to named session

Share a screen session

screen -S name # start and name the screen
Ctrl-a :multiuser on # add multiuser support
Ctrl-a :acladd userids # share the screen to userids (comma sep)

screen -x username/session # attach to the screen (in mirror)

Change permissions on a shared session
Ctrl-a :aclchg userids [permbits] [list]
# permbits = rwx and prefixed by "-" or "+"
# list of commands - #(all windows), ?(all commands)

Remove user access
acldel userids

Lock a Screen
ctrl-a ctrl-x # requires user to enter password to unlock

Copy and Paste from the screen scrollback buffer
Ctrl-a [Esc] # enters scrollback editor (movement like vi)
[spacebar] # starts and stops a copy selection range
Ctrl-a :paste . # pastes the copy buffer to the term

Screenrc options:
/home/> vi .screenrc
#shell -bash
shell -ksh # Make Screenrc exe .profile file on login

# Set the scrollback buffer
defscrollback 5000

# Turn off the startup banner
startup_message off

# displays a status line at the bottom of the terminal window.
hardstatus alwayslastline "Screen: %w %c:%s %D, %M/%d/%Y "

# detach on hangup - if my dial-up session fails, screen will simply
# detach and let me re re-attach later
autodetach on

Split Screen
# Create two screens
screen # create first screen
CTRL-a c # create second screen session (1 screen instance, but 2 window sessions)
CTRL-a S # split the screen
CTRL-a TAB # move to the bottom part of the split
CTRL-a " # will prompt for a screen number. Choose 0 or 1 indicating the window session
CTRL-a Q # quit all splits except the current

Scrollback / Copy and Paste
CTRL-a [ or CTRL-a ESC # frees the cursor to move into scrollback buffer (Copy mode)
# ESC to exit copy mode without copying
# use arrow keys or h,j,k,l to navigate in copy mode
# use CTRL-F and CTRL-B to page up and down in copy mode

ENTER # indicates a start point for text copy
ENTER # (second) indicates an end point for text copy
CTRL-a ] # pastes copied text range

No comments: