Skip to content

Instantly share code, notes, and snippets.

@thirdreplicator
Created June 5, 2011 06:18
Show Gist options
  • Save thirdreplicator/1008707 to your computer and use it in GitHub Desktop.
Save thirdreplicator/1008707 to your computer and use it in GitHub Desktop.
Notes on command-line utility "screen"
# Put this in ~/.screenrc:
# This will remap CTRL-A (the normal screen command-mode toggle key combo) to CTRL-Z,
# because I like to preserve CTRL-A to go to the beginning of the command line.
defscrollback 5000
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
# .screenrc
# EOF
### BEGIN NOTES ON HOW TO USE "SCREEN" ####
# To remap the CTRL-z to CTRL-z. (So that you can use CTRL-A to go to the beginning of the line.)
screen -e^Zz
# From now on, I will use "CTRL-z" for the first because that's what I remapped the base screen command (CTRL-a by default) to when typing in the "-e^Zz" option above. The reason I remapped it is because CTRL-a usually brings the cursor to the beginning of the line in bash. I use that a lot when working at the command line, so I want to preserve that bash mapping.
# To create a new screen buffer:
CTRL-z CTRL-c
# When logging in again, and reusing your previous screen session
screen -rd
# To kill a buffer
exit
# To move to a different screen buffer, say, 42
CTRL-z 42
# To toggle to the previous buffer
CTRL-z CTRL-a
# View a list of screen sessions
screen -list
# Create a named screen session called "work"
screen -S work
# Resume a named screen session called "work"
screen -r work
# Resume a named screen session called "work" in yet another terminal
screen -x -r work
# To scroll up, first go into "copy mode." To get into copy mode:
CTRL-z [
# In copy mode, to scroll up, use the vi navigation commands or arrow keys.
CTRL-B to go up one page
CTRL-F to go down one page
# To exist "copy mode":
ESC
# Name your window buffer
CTRL-z SHIFT-a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment