# ============================================================================== # basic screen settings # don't display lengthy license and version information on startup startup_message off # don't log new windows to utmp (who and such won't work, which is fine) deflogin off # automatically detach on terminal hangup (so that one can attach again and # continue working) autodetach on # ignore case on searches in copy-mode ignorecase on # assume UTF-8 encoding defutf8 on # use 256-color palette term screen-256color # no visual bell vbell off # disable flow control as it conflicts with Ctrl-S prefix defflow off # erase background with current bg color defbce on # remove delay after pressing escape key inside screen maptimeout 0 # start screen with a new layout (none by default) layout new initial # wait up to three seconds before hiding last message (default is 5 seconds) msgwait 3 # ============================================================================== # some xterm specific magic (not sure if it's actually required, but it was in # default configuration file) # terminfo and termcap for nice 256 color terminal # tell screen how to set colors. AB = background, AF=foreground termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm' # xterm-52 tweaks: # - uses background color for delete operations termcapinfo xterm be # tell xterm to enable scrolling when 'screen' is running termcapinfo xterm ti@:te@ # xterm understands both im/ic and doesn't have a status line. termcap xterm hs@:cs=\E[%i%d;%dr:im=\E[4h:ei=\E[4l terminfo xterm hs@:cs=\E[%i%p1%d;%p2%dr:im=\E[4h:ei=\E[4l # 80/132 column switching must be enabled for ^AW to work # change init sequence to not switch width termcapinfo xterm Z0=\E[?3h:Z1=\E[?3l:is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l # make the output buffer large for (fast) xterms. termcapinfo xterm* OL=10000 # tell screen that xterm can switch to dark background and has function keys termcapinfo xterm 'VR=\E[?5h:VN=\E[?5l' termcapinfo xterm 'k1=\E[11~:k2=\E[12~:k3=\E[13~:k4=\E[14~' termcapinfo xterm 'kh=\EOH:kI=\E[2~:kD=\E[3~:kH=\EOF:kP=\E[5~:kN=\E[6~' # special xterm hardstatus: use the window title termcapinfo xterm 'hs:ts=\E]2;:fs=\007:ds=\E]2;screen\007' termcapinfo xterm 'vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l' # emulate part of the 'K' charset termcapinfo xterm 'XC=K%,%\E(B,[\304,\\\\\326,]\334,{\344,|\366,}\374,~\337' # xterm-52 tweak: use background color for delete operations termcapinfo xterm* be # ============================================================================== # parameters of windows # enable alternative screen altscreen on # use big scrollback buffer defscrollback 5000 # suppress trailing blank lines when scrolling up text into the history buffer compacthist on # ============================================================================== # looks # set title automatically based on terminal prompt (requires additional # configuration of the prompt) shelltitle '$ |bash' # set color of borders and command-line (cyan background, black foreground) rendition so = ck # status line with current window highlighted hardstatus alwayslastline '%{Rk}%?%{dd}%E ESC %{Rk}%: %?%=%?%{gk} %-Lw%?%{kW} %n*%f%t%?(%u)%? %{= gk}%?%+Lw %{Rk}%:%{Rk} %?%=' # ============================================================================== # keybindings # change prefix key to Ctrl-S escape "^S^S" # vim-like navigation between windows bind h focus left bind j focus down bind k focus up bind l focus right # switch to previous window bind ' ' other # reload configuration file (note that this creates extra layout) bind r source ~/.screenrc # create new window with a shell prompt bind C screen # split horizontally creating new shell prompt bind - eval split 'focus down' screen # split vertically creating new shell prompt bind | eval 'split -v' 'focus right' screen # most of the time it's handy to kill a region and window simultaneously, so # make it easy to do with "x" bind x eval kill remove # ------------------------------------------------------------------------------ # layouts # create new layout with a shell prompt bind c eval 'layout new' screen # switch between layouts with Alt+Number bindkey "^[0" layout select 0 bindkey "^[1" layout select 1 bindkey "^[2" layout select 2 bindkey "^[3" layout select 3 bindkey "^[4" layout select 4 bindkey "^[5" layout select 5 bindkey "^[6" layout select 6 bindkey "^[7" layout select 7 bindkey "^[8" layout select 8 bindkey "^[9" layout select 9 # switch to next layout bind n layout next # switch to previous layout bind p layout prev # create new empty layout bind N layout new # remove current layout bind q layout remove # ------------------------------------------------------------------------------ # copy-mode # http://snarfed.org/synchronizing_gnu_screens_paste_buffer_and_the_x_selection # v - start selection # y - start line-wise selection # J - scroll down # K - scroll up markkeys "^M=v:y=V:^E=J:^Y=K" # > - copy selection to system clipboard bindkey -m > eval "stuff ' '" writebuf "exec sh -c 'xsel < /tmp/screen-exchange'" # ------------------------------------------------------------------------------ # resize-mode # https://gist.github.com/joaopizani/2718397 # put screen into resize mode bind R command -c rsz # 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" # use HJKL keys to move between regions bind -c rsz H eval "focus left" "command -c rsz" bind -c rsz J eval "focus down" "command -c rsz" bind -c rsz K eval "focus up" "command -c rsz" bind -c rsz L eval "focus right" "command -c rsz"