Instantly share code, notes, and snippets.

Embed
What would you like to do?
A killer GNU Screen Config
# the following two lines give a two-line status, with the current window highlighted
hardstatus alwayslastline
hardstatus string '%{= kG}[%{G}%H%? %1`%?%{g}][%= %{= kw}%-w%{+b yk} %n*%t%?(%u)%? %{-}%+w %=%{g}][%{B}%m/%d %{W}%C%A%{g}]'
# huge scrollback buffer
defscrollback 5000
# no welcome message
startup_message off
# 256 colors
attrcolor b ".I"
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
defbce on
# mouse tracking allows to switch region focus by clicking
mousetrack on
# default windows
screen -t Shell1 1 bash
screen -t Shell2 2 bash
screen -t Python 3 python
screen -t Media 4 bash
select 0
bind c screen 1 # window numbering starts at 1 not 0
bind 0 select 10
# get rid of silly xoff stuff
bind s split
# layouts
layout autosave on
layout new one
select 1
layout new two
select 1
split
resize -v +8
focus down
select 4
focus up
layout new three
select 1
split
resize -v +7
focus down
select 3
split -v
resize -h +10
focus right
select 4
focus up
layout attach one
layout select one
# navigating regions with Ctrl-arrows
bindkey "^[[1;5D" focus left
bindkey "^[[1;5C" focus right
bindkey "^[[1;5A" focus up
bindkey "^[[1;5B" focus down
# switch windows with F3 (prev) and F4 (next)
bindkey "^[OR" prev
bindkey "^[OS" next
# switch layouts with Ctrl+F3 (prev layout) and Ctrl+F4 (next)
bindkey "^[O1;5R" layout prev
bindkey "^[O1;5S" layout next
# F2 puts Screen into resize mode. Resize regions using hjkl keys.
bindkey "^[OQ" eval "command -c rsz" # enter resize mode
# use hjkl keys to resize regions
bind -c rsz h eval "resize -h -5" "command -c rsz"
bind -c rsz j eval "resize -v -5" "command -c rsz"
bind -c rsz k eval "resize -v +5" "command -c rsz"
bind -c rsz l eval "resize -h +5" "command -c rsz"
# quickly switch between regions using tab and arrows
bind -c rsz \t eval "focus" "command -c rsz" # Tab
bind -c rsz -k kl eval "focus left" "command -c rsz" # Left
bind -c rsz -k kr eval "focus right" "command -c rsz" # Right
bind -c rsz -k ku eval "focus up" "command -c rsz" # Up
bind -c rsz -k kd eval "focus down" "command -c rsz" # Down
@SteveRodrigue

This comment has been minimized.

Show comment
Hide comment
@SteveRodrigue

SteveRodrigue Jun 3, 2016

Really like your config file!

Is there a way to move the status windows from bottom to top of the screen?
Thanks!

SteveRodrigue commented Jun 3, 2016

Really like your config file!

Is there a way to move the status windows from bottom to top of the screen?
Thanks!

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Feb 13, 2017

This rocks!

ghost commented Feb 13, 2017

This rocks!

@pvalena

This comment has been minimized.

Show comment
Hide comment
@pvalena

pvalena Jul 3, 2017

wow :)

One additional from me:
bind v eval "writebuf" "exec sh -c 'exec xsel -b --display :0 -i < /tmp/screen-exchange'"

C-a v sets your X clipboard to the content of screens copy buffer.

pvalena commented Jul 3, 2017

wow :)

One additional from me:
bind v eval "writebuf" "exec sh -c 'exec xsel -b --display :0 -i < /tmp/screen-exchange'"

C-a v sets your X clipboard to the content of screens copy buffer.

@slugsuresh

This comment has been minimized.

Show comment
Hide comment
@slugsuresh

slugsuresh Aug 16, 2017

screen newbie question .

if i stick the following into my .screenrc, what command should i be running to
resize the screen windows ?

i tried F2 and ctrl F2 and tried ctrl A + h etc.
didnt seem to work ?

F2 puts Screen into resize mode. Resize regions using hjkl keys.

bindkey "^[OQ" eval "command -c rsz" # enter resize mode

use hjkl keys to resize regions

bind -c rsz h eval "resize -h -5" "command -c rsz"
bind -c rsz j eval "resize -v -5" "command -c rsz"
bind -c rsz k eval "resize -v +5" "command -c rsz"
bind -c rsz l eval "resize -h +5" "command -c rsz"

slugsuresh commented Aug 16, 2017

screen newbie question .

if i stick the following into my .screenrc, what command should i be running to
resize the screen windows ?

i tried F2 and ctrl F2 and tried ctrl A + h etc.
didnt seem to work ?

F2 puts Screen into resize mode. Resize regions using hjkl keys.

bindkey "^[OQ" eval "command -c rsz" # enter resize mode

use hjkl keys to resize regions

bind -c rsz h eval "resize -h -5" "command -c rsz"
bind -c rsz j eval "resize -v -5" "command -c rsz"
bind -c rsz k eval "resize -v +5" "command -c rsz"
bind -c rsz l eval "resize -h +5" "command -c rsz"

@PierreA-Drac

This comment has been minimized.

Show comment
Hide comment
@PierreA-Drac

PierreA-Drac Nov 12, 2017

Amazing ! You have really increased my Screen productivity with your keyboard shortcuts. Thanks a lot !

PierreA-Drac commented Nov 12, 2017

Amazing ! You have really increased my Screen productivity with your keyboard shortcuts. Thanks a lot !

@fejese

This comment has been minimized.

Show comment
Hide comment
@fejese

fejese Dec 27, 2017

Just small addition to "reset" the region sizes with "=" in resize mode:

bind -c rsz = eval "resize =" "command -c rsz"

fejese commented Dec 27, 2017

Just small addition to "reset" the region sizes with "=" in resize mode:

bind -c rsz = eval "resize =" "command -c rsz"
@tobiasandersen01

This comment has been minimized.

Show comment
Hide comment
@tobiasandersen01

tobiasandersen01 Jan 26, 2018

Been looking for how to bind non-alphanumeric keys, thank you!

tobiasandersen01 commented Jan 26, 2018

Been looking for how to bind non-alphanumeric keys, thank you!

@theFuzzyWebDev

This comment has been minimized.

Show comment
Hide comment
@theFuzzyWebDev

theFuzzyWebDev Mar 31, 2018

Fantastic! A massive thanks for this.

theFuzzyWebDev commented Mar 31, 2018

Fantastic! A massive thanks for this.

@bcutter

This comment has been minimized.

Show comment
Hide comment
@bcutter

bcutter Apr 6, 2018

First of all: thank you! As I´m new to this screen-rc-ing, I don´t know why but - some of your keys aren´t working for me. E. g. F2: when pressing F2, it only puts "~" on the shell in first area and makes a sound. [CTRL] + [A] + [F2] on the other hand says "Copy mode aborted" in status bar. What am I doing wrong here?

bcutter commented Apr 6, 2018

First of all: thank you! As I´m new to this screen-rc-ing, I don´t know why but - some of your keys aren´t working for me. E. g. F2: when pressing F2, it only puts "~" on the shell in first area and makes a sound. [CTRL] + [A] + [F2] on the other hand says "Copy mode aborted" in status bar. What am I doing wrong here?

@nyrahul

This comment has been minimized.

Show comment
Hide comment
@nyrahul

nyrahul Jun 11, 2018

If i turn use the 'mousetrack on', then select-copy-paste does not work anymore using mouse (without mousetrack=on, the copy paste works). Is there a way to enable both ? I m using putty to ssh to ubuntu 16.04 and using screen on ubuntu with this config.

nyrahul commented Jun 11, 2018

If i turn use the 'mousetrack on', then select-copy-paste does not work anymore using mouse (without mousetrack=on, the copy paste works). Is there a way to enable both ? I m using putty to ssh to ubuntu 16.04 and using screen on ubuntu with this config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment