Skip to content

Instantly share code, notes, and snippets.

@phawk
Last active November 8, 2021 01:49
Show Gist options
  • Save phawk/b2b3f1e28f8ffc33b396 to your computer and use it in GitHub Desktop.
Save phawk/b2b3f1e28f8ffc33b396 to your computer and use it in GitHub Desktop.
Sample screenrc
# Save this in ~/.screenrc
# Use bash
shell /bin/bash
autodetach on
# Big scrollback
defscrollback 5000
# No annoying startup message
startup_message off
# Display the status line at the bottom
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.kW}%-w%{.bW}%t [%n]%{-}%+w %=%{..G} %H %{..Y} %Y/%m/%d %c"
# Setup screens
chdir /home/vagrant/Sites # All screens start in ~/Sites folder
screen -t 'server' 0 bash # Make first screen for running server
screen -t 'specs' 1 bash # Make screen for running tests
screen -t 'workspace' 2 bash # Make screen for general work i.e. running git commands
# Switch to the workspace screen
select 2
# termcapinfo xterm ti@:te@
termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007:ti@:te@'
# From http://www4.informatik.uni-erlangen.de/~jnweiger/screen-faq.html
# Q: My xterm scrollbar does not work with screen.
# A: The problem is that xterm will not allow scrolling if the alternate text buffer is selected. The standard definitions of the termcap initialize capabilities ti and te switch to and from the alternate text buffer. (The scrollbar also does not work when you start e.g. ‘vi’). You can tell screen not to use these initialisations by adding the line “termcapinfo xterm ti@:te@” to your ~/.screenrc file.

Install screen

  • Screen comes preinstalled on Mac, though doesn’t support 256 colours

    $ brew tap homebrew/dupes
    $ brew install screen
  • Install screen on ubuntu

    $ sudo apt-get update
    $ sudo apt-get install screen

Basic usage

# Open or resume screen session
$ screen -DR

# Close screen session
[Ctrl + a] then [d]

# Switch windows
[Ctrl + a] then [number of screen you want to switch to]

# Open a new window
[Ctrl + a] then [c]

# Close a window
$ exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment