Skip to content

Instantly share code, notes, and snippets.

@yoshikaw
Created May 18, 2013 11:53
Show Gist options
  • Save yoshikaw/5604167 to your computer and use it in GitHub Desktop.
Save yoshikaw/5604167 to your computer and use it in GitHub Desktop.
# my screenrc for Debian GNU/Linux 7.0(wheezy)
# Escape key is C-t, literal is a.
escape ^Ta
# Appearance {{{1
#-------------------------------------------------------------------------------
# tab like hardstatus, and caption shows un-focused window clearly
caption always "%?%F%{Wk}%:%{KW}%?%?%E%{Yr}%? %n %?%F%:%{Kw}%?%{.r}%f%{-}%?%F%{wk}%:%{.k}%?%e %?%F%{gW}%{Yr}%:%{.w}%{yr}%?%?%P%:%{-}%? %?%E%{.r}%?%t%040=%?%F%{Yr}%:%{yr}%?%?%P<< copy/scrollback mode. >>%:%{-}%{.k}%? %h%="
hardstatus alwayslastline "%m/%d %02c:%s %?%E%{Yr}%:%{.g}%?%H%{-} %L=%-Lw%45L>%?%E%{Yr}%:%{Wk}%?%n%{.r}%f%{-}%{-}%{gW} %t %{-}%+Lw %-17<%=%{.y}(%l)"
# changes the windowlist format to suit caption/hardstatus
windowlist title "%{+u}%{.g} Num %{-}%{.y}Flags %{-}%{.w}Title%040=Hardstatus%="
windowlist string "%{.g}%4n%04=%{-}%{.y}%f%{-}%012=%t%040=%h%="
# change the colors used in vertical border line, command input area, selection of window list.
#sorendition '=' 'KW'
rendition so '=' 'KW'
rendition silence 'wk'
rendition bell 'yr'
# Use bright colors for bold text.
attrcolor b ".I"
# Unused default key bindings {{{1
#-------------------------------------------------------------------------------
bind b # break
bind ^B # break
bind D # pow_detach
bind k # kill
bind ^K # kill
bind q # xon
bind ^Q # xon
bind s # xoff
bind ^S # xoff
bind W # width
bind x # lockscreen
bind ^X # lockscreen
bind Z # reset
bind z # suspend
bind ^Z # suspend
bind ^\ # quit
# disables vbell toggle binding to use ^G as cancel.
bind ^G
# Window {{{1
#-------------------------------------------------------------------------------
# the $TERM variable set to `xterm' for various environment.
term xterm
# shortcut of screen sub-command with title option.
bind s colon 'screen -t '
# list of all windows is displayed for visual window selection.
# override default `w'(windows) mapping.
# show the windows inside any groups in current level and downwards.
bind w windowlist -g
bind ^W windowlist -g -m # sorting by most-recently-used list.
# continuous switch to other window
bind ^N eval 'next' 'command -c select'
bind ^P eval 'prev' 'command -c select'
bind -c select ^N eval 'next' 'command -c select'
bind -c select ^P eval 'prev' 'command -c select'
# window re-numbering
# override default `N'(number) mapping
bind N colon 'number '
# control message line
bind J eval 'command -c messageline' 'echo "[Message Line] hardstatus: [a]lwayslastline [i]gnore [l]astline [m]essage / caption: al[w]ays [s]plitonly / [.] restore all [_] ignore all"'
bind -c messageline a eval 'hardstatus alwayslastline'
bind -c messageline i eval 'hardstatus ignore'
bind -c messageline l eval 'hardstatus lastline'
bind -c messageline m eval 'hardstatus message'
bind -c messageline w eval 'caption always'
bind -c messageline s eval 'caption splitonly'
bind -c messageline _ eval 'hardstatus ignore' 'caption splitonly'
bind -c messageline . eval 'hardstatus alwayslastline' 'caption always'
# Region {{{1
#-------------------------------------------------------------------------------
# switch focus to other region(like vim)
# orverride default `k'(kill), `t'(time), `b'(break) mappings.
bind j focus down
bind k focus up
bind t focus top
bind b focus bottom
# override default `h'(hardcopy), `l'(redisplay) mapping
bind h focus left
bind l focus right
# continuous region operations(like vim)
# orverride default `^R'(wrap) mapping.
bind r eval 'command -c region' 'echo "[Region]"'
bind ^R eval 'command -c region' 'echo "[Region]"'
bind ^J eval 'focus down' 'command -c region' 'echo "[Region] (focus down)"'
bind ^K eval 'focus up' 'command -c region' 'echo "[Region] (focus up)"'
bind -c region ^J eval 'focus down' 'command -c region' 'echo "[Region] (focus up)"'
bind -c region ^K eval 'focus up' 'command -c region' 'echo "[Region] (focus up)"'
bind -c region ^T eval 'focus top' 'command -c region' 'echo "[Region] (focus top)"'
bind -c region ^B eval 'focus bottom' 'command -c region' 'echo "[Region] (focus bottom)"'
###bind -c region ^N eval 'focus down' 'command -c region' 'echo "[Region] (focus down)"'
###bind -c region ^P eval 'focus up' 'command -c region' 'echo "[Region] (focus up)"'
bind -c region + eval 'resize +1' 'command -c region' 'echo "[Region] (resize +1)"'
bind -c region - eval 'resize -1' 'command -c region' 'echo "[Region] (resize -1)"'
###bind -c region j eval 'resize +1' 'command -c region' 'echo "[Region] (resize +1)"'
###bind -c region k eval 'resize -1' 'command -c region' 'echo "[Region] (resize -1)"'
###bind -c region J eval 'resize +10' 'command -c region' 'echo "[Region] (resize +10)"'
###bind -c region K eval 'resize -10' 'command -c region' 'echo "[Region] (resize -10)"'
###bind -c region = eval 'resize =' 'command -c region' 'echo "[Region] (resize =)"'
bind -c region . eval 'resize min' 'command -c region' 'echo "[Region] (resize min)"'
bind -c region _ eval 'resize max' 'command -c region' 'echo "[Region] (resize max)"'
bind -c region n eval 'split' 'command -c region' 'echo "[Region] (split)"'
bind -c region s eval 'split' 'focus down' 'other' 'command -c region' 'echo "[Region] (split)"'
bind -c region c eval 'remove' 'command -c region' 'echo "[Region] (remove)"'
bind -c region o eval 'only' 'command -c region' 'echo "[Region] (only)"'
# just a little like emacs
bind -c region 1 eval 'only' 'command -c region' 'echo "[Region] (split)"'
bind -c region 2 eval 'split' 'command -c region' 'echo "[Region] (split)"'
bind -c region 3 eval 'split -v' 'command -c region' 'echo "[Region] (split -v)"'
# re-define continuous region operation (vertical resize locally and focus next/prev)
bind -c region ^N eval 'focus next' 'command -c region' 'echo "[Region] (focus next)"'
bind -c region ^P eval 'focus prev' 'command -c region' 'echo "[Region] (focus prev)"'
bind -c region j eval 'resize -l -v +1' 'command -c region' 'echo "[Region] (resize -l -v +1)"'
bind -c region k eval 'resize -l -v -1' 'command -c region' 'echo "[Region] (resize -l -v -1)"'
bind -c region J eval 'resize -l -v +10' 'command -c region' 'echo "[Region] (resize -l -v +10)"'
bind -c region K eval 'resize -l -v -10' 'command -c region' 'echo "[Region] (resize -l -v -10)"'
bind -c region = eval 'resize -l =' 'command -c region' 'echo "[Region] (resize -l =)"'
# add continuous region operation(like vim)
bind -c region ^H eval 'focus left' 'command -c region' 'echo "[Region] (focus left)"'
bind -c region ^L eval 'focus right' 'command -c region' 'echo "[Region] (focus right)"'
bind -c region < eval 'resize -l -h -1' 'command -c region' 'echo "[Region] (resize -l -h -1)"'
bind -c region > eval 'resize -l -h +1' 'command -c region' 'echo "[Region] (resize -l -h +1)"'
bind -c region ( eval 'resize -l -h -10' 'command -c region' 'echo "[Region] (resize -l -h -10)"'
bind -c region ) eval 'resize -l -h +10' 'command -c region' 'echo "[Region] (resize -l -h +10)"'
bind -c region h eval 'resize -l -h -1' 'command -c region' 'echo "[Region] (resize -l -h -1)"'
bind -c region l eval 'resize -l -h +1' 'command -c region' 'echo "[Region] (resize -l -h +1)"'
bind -c region H eval 'resize -l -h -10' 'command -c region' 'echo "[Region] (resize -l -h -10)"'
bind -c region L eval 'resize -l -h +10' 'command -c region' 'echo "[Region] (resize -l -h +10)"'
bind -c region ^V eval 'split -v' 'command -c region' 'echo "[Region] (split -v)"'
bind -c region v eval 'split -v' 'command -c region' 'echo "[Region] (split -v)"'
bind -c region | eval 'split -v' 'command -c region' 'echo "[Region] (split -v)"'
bind -c region 1 eval 'only' 'command -c region' 'echo "[Region] (split)"'
bind -c region 2 eval 'split' 'command -c region' 'echo "[Region] (split)"'
bind -c region 3 eval 'split -v' 'command -c region' 'echo "[Region] (split -v)"'
# greedy continuous resize region
#bind -c region ^J eval 'resize -v +1' 'command -c region' 'echo "[Region] (resize -v +1)"'
#bind -c region ^K eval 'resize -v -1' 'command -c region' 'echo "[Region] (resize -v -1)"'
#bind -c region ^H eval 'resize -h -1' 'command -c region' 'echo "[Region] (resize -h -1)"'
#bind -c region ^L eval 'resize -h +1' 'command -c region' 'echo "[Region] (resize -h +1)"'
# Copy and Paste {{{1
#-------------------------------------------------------------------------------
# I like a large scrollback buffer.
defscrollback 10000
# changes the filename used for reading and writing with the paste buffer.
bufferfile "$SCREEN_EXCHANGE_FILE"
# copy the screen paste buffer to the OS clipboard automatically
bindkey -m ' ' eval 'stuff \040' 'writebuf' 'exec sh -c "$SCREEN_COPY_COMMAND < $SCREEN_EXCHANGE_FILE"'
bindkey -m Y eval 'stuff Y' 'writebuf' 'exec sh -c "$SCREEN_COPY_COMMAND < $SCREEN_EXCHANGE_FILE"'
bindkey -m W eval 'stuff W' 'writebuf' 'exec sh -c "$SCREEN_COPY_COMMAND < $SCREEN_EXCHANGE_FILE"'
# copy the paste buffer to remote clipboard
# orverride default `^]'(paste .) mapping.
# http://yskwkzhr.blogspot.com/2011/04/copying-remote-screen-paste-buffer.html
bind ^] eval 'writebuf' 'exec sh -c "cat $SCREEN_EXCHANGE_KEY $SCREEN_EXCHANGE_FILE | nc -w1 localhost 52224"' 'echo "paste to remote"'
# to yank/put registers easily.
bind Y eval 'colon "paste . "' 'echo "specify the destination register: "'
bind P colon 'paste '
# Logging {{{1
#-------------------------------------------------------------------------------
# changes the directory for hardcopy.
hardcopydir 'screen/hardcopy'
# changes the name of logfile.
logtstamp on
logtstamp string "\n-- SCREEN [%Y/%m/%d %02c:%s] %n:%t --\n"
logfile 'screen/log/screenlog.%H.%Y%m%d_%02c:%s-%02n.%t.log'
# Virtual Terminal {{{1
#-------------------------------------------------------------------------------
# a window title is also displayed on a bell msg
bell_msg 'Bell in window %n (%t)'
# enable visual vells
vbell on
# enable background-color-erase setting.
defbce on
# treat ambiguous characters as full width
# https://savannah.gnu.org/bugs/?16666
cjkwidth on
# to switch window encoding, and set the relevant environment variables.(for b-shell)
bind ^E eval 'command -c encoding' 'echo "switch window encoding to: [u]tf8 [e]ucjp [s]jis [j]is / with env [U]tf8 [E]ucjp [S]jis"'
bind -c encoding ^U eval 'encoding utf8' 'info'
bind -c encoding u eval 'encoding utf8' 'info'
bind -c encoding ^E eval 'encoding eucjp' 'info'
bind -c encoding e eval 'encoding eucjp' 'info'
bind -c encoding ^S eval 'encoding sjis' 'info'
bind -c encoding s eval 'encoding sjis' 'info'
bind -c encoding ^J eval 'encoding jis' 'info'
bind -c encoding j eval 'encoding jis' 'info'
bind -c encoding U eval 'encoding utf8' 'stuff "LANG=ja_JP.UTF-8; export LANG\012"' 'info'
bind -c encoding E eval 'encoding eucjp' 'stuff "LANG=ja_JP.eucJP; export LANG\012"' 'info'
bind -c encoding S eval 'encoding sjis' 'stuff "LANG=ja_JP.sjis; export LANG\012"' 'info'
# Termcap {{{1
#-------------------------------------------------------------------------------
# enable 256 color
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
# don't resize terminal width when re-attached.
termcapinfo xterm 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l'
# don't use alternate screen
termcapinfo xterm* ti@:te@
# Misc {{{1
#-------------------------------------------------------------------------------
# don't show startup message.
startup_message off
# changes the kind of messages to the nethack-style.
nethack on
# echo command name whenever a window is created or resurrected.
verbose on
# don't remove windows from the window list as soon as window process exits.
zombie kr # k: destory window, r: resurrect window
# reload screenrc
# override default `.'(dumptermcap) mapping.
bind . eval 'source $SCREENRC' 'echo "Reloaded: $SCREENRC"'
# Switch toggle option easily.
bind o eval 'command -c toggleoption' 'echo "[Toggle Option] [a]ltscreen [b]ce [h]ardcopy_append [m]ousetrack [w]rap [v]bell"'
bind -c toggleoption a altscreen
bind -c toggleoption b bce
bind -c toggleoption h eval 'command -c toggleoption_h' 'echo "[Toggle Option] (hardcopy_append) [o]on [f]off"'
bind -c toggleoption_h o hardcopy_append on
bind -c toggleoption_h f hardcopy_append off
bind -c toggleoption m eval 'command -c toggleoption_m' 'echo "[Toggle Option] (mousetrack) [o]on [f]off"'
bind -c toggleoption_m o mousetrack on
bind -c toggleoption_m f mousetrack off
bind -c toggleoption v vbell
bind -c toggleoption w wrap
# Layout {{{1
#-------------------------------------------------------------------------------
# trigger for layout sub-commands
bind ^Y eval 'command -c layout' 'layout show'
bind y eval 'command -c layout' 'layout show'
# create/remove layout
bind -c layout c eval 'layout new' 'layout show'
bind -c layout X eval 'layout remove' 'layout show'
# change the current layout title or number
bind -c layout A colon 'layout title '
bind -c layout N colon 'layout number '
# switch to the layout identified by number or title (not prefix of a title)
bind -c layout \' eval 'layout select' 'layout show'
# continuous switch to another layout
bind -c layout ^N eval 'layout next' 'command -c layout' 'layout show'
bind -c layout ^P eval 'layout prev' 'command -c layout' 'layout show'
# switch to another layout
bind -c layout n eval 'layout next'
bind -c layout p eval 'layout prev'
bind -c layout 0 eval 'layout select 0'
bind -c layout 1 eval 'layout select 1'
bind -c layout 2 eval 'layout select 2'
bind -c layout 3 eval 'layout select 3'
bind -c layout 4 eval 'layout select 4'
bind -c layout 5 eval 'layout select 5'
bind -c layout 6 eval 'layout select 6'
bind -c layout 7 eval 'layout select 7'
bind -c layout 8 eval 'layout select 8'
bind -c layout 9 eval 'layout select 9'
# Include host local configuration {{{1
#-------------------------------------------------------------------------------
###source '.screenrc.local'
################################################################################
###
### Split following setting to another file (e.g. `.screenrc.startup').
### And start up with that file. (`screen -c $HOME/.screenrc.startup')
###
################################################################################
# GNU Screen startup file
# include default .screenrc
#source $HOME/.screenrc
# Window Group {{{1
#-------------------------------------------------------------------------------
screen -t Main 99 //group
screen -t Monitor 98 //group
select -
# Window {{{1
#-------------------------------------------------------------------------------
select Main
screen 0
screen 1
screen 2
screen 3
screen 4
select Monitor
screen -t top 89 top
screen -t echo-sd 88
# exit the window group
select -
# Layout {{{1
#-------------------------------------------------------------------------------
# vertial layout {{{2
layout new 0:vertical
# +-------------------------------------+--------------------------------------+
# | | |
# | +--------------------------------------+
# | | |
# +-------------------------------------+--------------------------------------+
# | | |
# | +-------------------+------------------+
# | | | |
# +---------------------------------------------------------+------------------+
split -v
select top
split
focus down
select 0
focus right
split
split
split
select 88
focus next
select 1
focus next
select 2
focus bottom
select 3
split -v
focus bottom
select 4
focus up
# horizonal layout {{{2
layout new 1:horizontal
# +----------------------------------------------------------------------------+
# | |
# | |
# | |
# | |
# +-------------------+-----------------+-------------------+------------------+
# | | | | |
# +-------------------+-------------------------------------+------------------+
select 2
split
focus down
select 1
split -v
split -v
split -v
focus next
select 0
focus right
select 3
focus bottom
select 4
resize -v -l 20%
focus top
# single layout {{{2
layout new 2:single
select 2
stuff "echo here is current window\n"
#}}}
layout select 0
# expand window group at windowlist on window 99(Main)
focus left
focus down
select Main
stuff 'g'
# call echo-sd on window 88(echo-sd)
focus up
focus right
#stuff "which wget &>/dev/null && wget -q -O- 'http://www.osstech.co.jp/cgi-bin/echo-sd?scripts=&options=text'\012"
# enter copy mode on window 1
focus down
copy
focus down
layout show
# vim: filetype=screen foldmethod=marker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment