Skip to content

Instantly share code, notes, and snippets.

@yoshikaw
Created November 2, 2010 22:09
Show Gist options
  • Save yoshikaw/660389 to your computer and use it in GitHub Desktop.
Save yoshikaw/660389 to your computer and use it in GitHub Desktop.
my GNU Screen setting at 2010/11/03
#
# .screenrc - GNU screen user configuration file
#
# $Id: .screenrc 190 2010-04-17 07:54:54Z yoshikaw $
#
# @see http://www.informatik.uni-hamburg.de/RZ/software/screen/screen_toc.html
# @see http://www.limy.org/program/screen_command.html
#
# Escape key is C-t, literal is a.
escape ^Ta
# I like a large scrollback buffer.
defscrollback 1000
# clear scrollback buffer
bind F eval 'scrollback 0' 'scrollback 1000' 'echo "scrollback buffer cleared"'
# don't show startup message.
startup_message off
# don't remove windows from the window list as soon as window process exits.
zombie kr # k: destory window, r: resurrect window
# echo command name whenever a window is created or resurrected.
verbose on
# changes the name of logfile.
logfile 'screen/log/screenlog.%H.%Y%m%d-%02c:%s-%n.%t.log'
logtstamp on
logtstamp string "\n-- SCREEN [%Y/%m/%d %02c:%s] %n:%t --\n"
# changes the directory for hardcopy.
hardcopydir 'screen/hardcopy'
hardcopy_append on
# changes the filename used for reading and writing with the paste buffer.
bufferfile 'screen/screen-exchange'
# changes the kind of messages to the nethack-style.
nethack on
# enable visual vells
vbell on
# disables vbell toggle binding to use ^G as cancel.
bind ^G
# window re-numbering
# override default `N'(number) mapping
bind N colon 'number '
# shortcut of screen sub-command with title option.
bind s colon 'screen -t '
# switch window encoding
bind ^U eval 'encoding utf8' 'info'
bind ^E eval 'encoding eucjp' 'info'
# switch window encoding and changes LANG environment variable.(for b-shell)
bind u eval 'encoding utf8' '!!!echo "LANG=ja_JP.utf8; export LANG"' 'info'
bind e eval 'encoding eucjp' '!!!echo "LANG=ja_JP.eucJP; export LANG"' 'info'
# switch focus to other region(like vi)
# 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
# continuous switch focus to other region(like vi)
bind ^J eval 'focus down' 'command -c cfocus'
bind ^K eval 'focus up' 'command -c cfocus'
bind -c cfocus ^J eval 'focus down' 'command -c cfocus'
bind -c cfocus ^K eval 'focus up' 'command -c cfocus'
bind -c cfocus ^T eval 'focus top' 'command -c cfocus'
bind -c cfocus ^B eval 'focus bottom' 'command -c cfocus'
# swap region to neighbour's
# orverride default `W'(width) mapping.
bind W eval 'command -c swap' 'echo "swap region to: [N]ext [P]rev"'
bind -c swap N eval 'select -' 'focus down' 'other' 'focus up' 'other' 'focus down'
bind -c swap P eval 'select -' 'focus up' 'other' 'focus down' 'other' 'focus up'
# continuous resize region
# orverride default `r'(wrap) mapping.
bind r eval 'command -c cresize'
bind -c cresize j eval 'resize +1' 'command -c cresize'
bind -c cresize k eval 'resize -1' 'command -c cresize'
bind -c cresize J eval 'resize +10' 'command -c cresize'
bind -c cresize K eval 'resize -10' 'command -c cresize'
bind -c cresize = eval 'resize =' 'command -c cresize'
bind -c cresize n eval 'resize min' 'command -c cresize'
bind -c cresize x eval 'resize max' 'command -c cresize'
# continuous switch to other window
bind ^N eval 'next' 'command -c cselect'
bind ^P eval 'prev' 'command -c cselect'
bind -c cselect ^N eval 'next' 'command -c cselect'
bind -c cselect ^P eval 'prev' 'command -c cselect'
# list of all windows is displayed in the blank window(-b) for visual window selection.
# override default `w'(windows) mapping.
bind w windowlist -b
bind ^W windowlist -b -m # sorting by most-recentry-used list.
# move cursor to begining of scrollback buffer(and move to the leftmost column of the window top)
bindkey -m ;b stuff "g/:\015\006\002"
# refuses yet another hack in rpm packaged screenrc.
# both ] and ^] does write the paste (default unnamed) buffer.
bind ^] paste .
# enable background-color-erase setting.
defbce on
# use bright colors for bold text.
attrcolor b '.I'
# the $TERM variable set to `xterm' for various environment.
term xterm
# 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'
# changes the windowlist format to suit caption/hardstatus
windowlist title '%{u .g}Num Flags Title%=[0-9] select the number [movement] j,C-n:Down k,C-p:Up (C-)f:PageDown (C-)b:PageUp'
windowlist string '%{.g}%3n %{.y}%f%09=%{dg} %t %='
# Give me some info at the bottom of each window and the bottom of screen like scrollable tabbed bar.
# e.g.:
# +----------------------------------------------------------------------------+
# | |
# | |
# | |
# | |
# +----------------------------------------------------------------------------+
# |11 top | <--- caption (bellow each window)
# +----------------------------------------------------------------------------+
# | |
# | |
# | |
# | |
# | |
# | |
# +----------------------------------------------------------------------------+
# | 2 vim | <--- caption
# +----------------------------------------------------------------------------+
# | |
# | |
# +----------------------------------------------------------------------------+
# | 3(L) tail | <--- caption
# +----------------------------------------------------------------------------+
# |09/24 13:23:54 hostname 0 zsh 1 man 2 vim 3 tail 11 to... (load average)| <--- hardstatus
# +----------------------------------------------------------------------------+
caption always '%?%F%{= gW}%:%{= Kk}%?%2n%f%07=%t%='
# caption string description:
#
# %? - Start of a conditional statement.
# %F - Use this part of the statement if the window has focus (i.e. it
# is the only window or the currently active one).
# %{= gW} - bright white on green.
# %: - else
# %{= Kk} - bright black on black
# %? - End conditional statement.
# %2n - number of the current window with left 2 padding
# %f - flags for current window
# %07= - left 7 padding for window number and flags
# %t - title of current window
# %= - truncation/padding point
hardstatus alwayslastline '%m/%d %02c:%s %{= .g}%H%{-} %L=%-w%45L>%{=u g.}%n %t%{-}%+w %-17<%=%{= .y}(%l)'
# hardstatus string description:
#
# %m - Two-letter month number
# %d - Two-letter day number
# %02c - time (hh:mm) in 24 hour format
# %s - seconds
# %{= .g} - green color on default background
# %H - host name.
# %{-} - undo last color change(so now we're back to default color)
# %L= - left padding start here
# %-w - window list up to but not including the current window (-)
# %45L> - truncation/padding marker; place this point about 45% of the
# way into the display area (45)
# %{=u g.} - default color on green, and underline.
# %n - number of the current window.
# %t - title of current window.
# %{-} - undo last color change
# %+w - window list from the next window on (-)
# %-17< - truncation/padding point. place this point zero spaces (0)
# from the right margin (-).
# %= - truncation/paddion point.
# %{= .y} - yellow on default background.
# %l - host load average.
# APPENDIX: STRING ESCAPES (make extracts from screen (1))
#
# The attribute set can either be specified as hexadecimal number
# or a combination of the following letters:
#
# d dim
# u underline
# b bold
# r reverse
# s standout
# B blinking
#
# Colors are coded either as a hexadecimal number or two letters specifying
# the desired background and foreground color (in that order).
# The following colors are known:
#
# k black
# r red
# g green
# y yellow
# b blue
# m magenta
# c cyan
# w white
# d default color
# . leave color unchanged
#
# The capitalized versions of the letter specify bright colors.
# You can also use the pseudo-color `i' to set just the brightness and leave the color unchanged.
# include hostlocal .screenrc
source '.screenrc.local'
#
# .screenrc.local - GNU screen host local user configuration file
#
# $Id: .screenrc.local.nadleeh 221 2010-05-09 12:04:11Z yoshikaw $
#
# copy the screen pastbuffer to the MacOSX pastebord
bindkey -m ' ' eval 'stuff \040' 'writebuf' 'exec sh -c "/usr/bin/pbcopy < screen/screen-exchange"'
bindkey -m Y eval 'stuff Y' 'writebuf' 'exec sh -c "/usr/bin/pbcopy < screen/screen-exchange"'
bindkey -m W eval 'stuff W' 'writebuf' 'exec sh -c "/usr/bin/pbcopy < screen/screen-exchange"'
# alias for remote login
# override default `^V'(digraph) mapping
bind ^V eval 'command -c rlogin' 'echo "login to: [0] [1]xeus [2]vmm.vm [3] [4]intra [5] [6] [7] [8] [9]qnap "'
bind -c rlogin 1 eval 'screen -t xeus 10 ssh xeus'
bind -c rlogin 2 eval 'screen -t vmm 20 ssh vmm'
bind -c rlogin 4 eval 'screen -t intra 40 ssh intra' eval 'encoding eucjp'
bind -c rlogin 9 eval 'screen -t qnap 90 ssh qnap'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment