2008/02/10

.screenrcを晒してみる

仕事がら複数のサーバで作業することが多いので2年ほど前からGNU Screenを使い始めましたが、非常に危険です、コレ。もうこれがないと生きてゆけなくなりました。せっかくなのでネット上での先駆者の設定を拝借したりしてコツコツとカスタマイズしてきた内容を晒してみます。

screenを使い始めた当時、今は亡きOpen Source Magazine 2006/5月号に特集が組まれていたのを必死で覚えました。気づくとその記事はIBM dW Japanに載っていました

私のカスタマイズの基本はこんな感じです。
  • デフォルトキーバインドはなるべく尊重
  • ただし危険そうなのは無効にする
  • ウィンドウの選択・リサイズなどは連続して実行する
  • caption/hardstatusでタブ風な外観を
現在はCVS版のscreenを常用していて、縦分割、レイアウトの保存など、早く正式版が待たれる機能が満載で益々手放せなくなっていますが、ここではリリース版で使っている.screenrcの一部を晒します。継続的なウィンドウの選択とリサイズは、画面3つ以上に縦分割・横分割したときに大活躍します。(ターミナルエミュレータは全画面で起動する派です)

#
# .screenrc - GNU screen user configuration file
#
# @version 20080210
# @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 t.
escape ^Tt

# I like a large scrollback
defscrollback 5000

# move cursor to begining of scroll buffer(and move to the leftmost column of the window top)
bindkey -m -t ;b stuff "g/:^M^F^B"

# sets the encoding of the default window.
defencoding eucJP

# don't update utmp database
###deflogin off

# 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

# disable default window killing keybinding
bind \\

# echo command name whenever a window is created or resurrected.
verbose on

# logging
logfile "screen/log/screenlog.%H.%Y%m%d-%c:%s.%n.%t.log"
logtstamp on

# hardcopy
hardcopydir screen/hardcopy

# bufferfile
bufferfile screen/screen-exchange

# changes the kind of messages to the nethack-style.
nethack on

# enable visual vells and disable vbell toggle binding
vbell on
bind ^G

# login shortcut
bind R colon 'screen ssh '
bind T colon 'screen telnet '

# encoding aliases
bind u  eval 'encoding utf8'  'info'
bind ^U eval 'encoding utf8'  'info'
bind e  eval 'encoding eucjp' 'info'
bind ^E eval 'encoding eucjp' 'info'

# resion focus(like vi)
bind j focus down
bind k focus up
bind t focus top
bind b focus bottom

# continuous resion focus(like vi)
bind ^J eval 'focus down' 'echo "Focus region: "' 'command -c cfocus'
bind ^K eval 'focus up'   'echo "Focus region: "' 'command -c cfocus'
bind -c cfocus ^J eval 'focus down' 'echo "Focus region: "' 'command -c cfocus'
bind -c cfocus ^K eval 'focus up'   'echo "Focus region: "' 'command -c cfocus'

# continuous resion resize.
# orverride default `r'(wrap) mapping.
bind r eval 'echo "Resize region:"' 'command -c cresize'
bind -c cresize j eval 'resize +1'  'echo "Resize region:"' 'command -c cresize'
bind -c cresize k eval 'resize -1'  'echo "Resize region:"' 'command -c cresize'
bind -c cresize J eval 'resize +10' 'echo "Resize region:"' 'command -c cresize'
bind -c cresize K eval 'resize -10' 'echo "Resize region:"' 'command -c cresize'
bind -c cresize 1 eval 'resize 10'  'echo "Resize region:"' 'command -c cresize'
bind -c cresize 2 eval 'resize 20'  'echo "Resize region:"' 'command -c cresize'
bind -c cresize 3 eval 'resize 30'  'echo "Resize region:"' 'command -c cresize'
bind -c cresize 4 eval 'resize 40'  'echo "Resize region:"' 'command -c cresize'
bind -c cresize 6 eval 'resize 50'  'echo "Resize region:"' 'command -c cresize'
bind -c cresize 6 eval 'resize 60'  'echo "Resize region:"' 'command -c cresize'
bind -c cresize 7 eval 'resize 70'  'echo "Resize region:"' 'command -c cresize'
bind -c cresize 7 eval 'resize 80'  'echo "Resize region:"' 'command -c cresize'
bind -c cresize 9 eval 'resize 90'  'echo "Resize region:"' 'command -c cresize'
bind -c cresize 0 eval 'resize 100' 'echo "Resize region:"' 'command -c cresize'
bind -c cresize = eval 'resize ='   'echo "Resize region:"' 'command -c cresize'
bind -c cresize m eval 'resize min' 'echo "Resize region:"' 'command -c cresize'
bind -c cresize x eval 'resize max' 'echo "Resize region:"' 'command -c cresize'

# continuous window select 
bind ^N eval 'next' 'echo "Select window:"' 'command -c cselect'
bind ^P eval 'prev' 'echo "Select window:"' 'command -c cselect'
bind -c cselect ^N eval 'next' 'echo "Select window:"' 'command -c cselect'
bind -c cselect ^P eval 'prev' 'echo "Select window:"' 'command -c cselect'

# display all windows in a table for visual window selection. (")
# override default `w'(windows) mapping.
bind w windowlist 
windowlist title 'Num Title%=Flags'

# Give me some info at the bottom of each window and the bottom of screen like scrollable tabbed bar.
# e.g.:
# +----------------------------------------------------------------------------+
# |                                                                            |
# |                                                                            |
# |                                                                            |
# |                                                                            |
# +----------------------------------------------------------------------------+
# | 0$    top                                                                  | <--- caption (bellow each window)
# +----------------------------------------------------------------------------+
# |                                                                            |
# |                                                                            |
# |                                                                            |
# |                                                                            |
# |                                                                            |
# |                                                                            |
# +----------------------------------------------------------------------------+
# | 2$    vim                                                                  | <--- caption
# +----------------------------------------------------------------------------+
# |                                                                            |
# |                                                                            |
# +----------------------------------------------------------------------------+
# | 3$(L) tail                                                                 | <--- caption
# +----------------------------------------------------------------------------+
# |[09/24 13:23:43]0 top  1 man  2 vim  3 tail  11 less  21 ssh  22 ssh  31 ssh| <--- hardstatus
# +----------------------------------------------------------------------------+

caption always "%?%F%{= bW}%:%{= wk}%?%2n%f%07=%t%="
# caption 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).
#  %{= bW}    - bright white on blue.
# %:          - else
#  %{= wk}    - black on white
# %?          - 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 "%{= Wb}[%m/%d %02c:%s]%016=%{= WK}%-w%50>%{= bW}%n %t%{-}%+w%-0< %="
# hardstatus description:
# 
# %{= Wb}     - blue on bright white
#  %m         - Two-letter month number
#  %d         - Two-letter day number
#  %02c       - time (hh:mm) in 24 hour format
#  %s         - seconds
#  %016=      - left 16 padding for datetime
# %{= WK}     - white on bright white
#  %-w        - window list up to but not including the current window (-)
#  %50>       - truncation/padding marker; place this point about 50% of the
#               way into the display area (50)
# %{=u bW}    - underline, blue on bright white
#  %n         - number of the current window
#  %t         - title of current window
# %{-}        - undo last color change(so now we're back to white on bright white)
#  %+w        - window list from the next window on (-)
#  %-0<       - truncation/padding point. place this point zero spaces (0) 
#               from the right margin (-).
#  %=         - truncation/paddion point. 

# 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.

0 件のコメント:

コメントを投稿