screenrc 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. # For a complete list of available commands, see http://bit.ly/jLtj
  2. # Set the default program for new windows.
  3. shell zsh
  4. # Set default lines of scrollback.
  5. defscrollback 5000 # default: 100
  6. # Detach session on hangup instead of terminating screen completely.
  7. autodetach on # default: on
  8. # Select line break behavior for copying.
  9. crlf off # default: off
  10. # Select default utmp logging behavior.
  11. #deflogin off # default: on
  12. # If set to 'on', screen will append to the 'hardcopy.n' files created by the
  13. # command hardcopy; otherwise, these files are overwritten each time.
  14. hardcopy_append on # default: off
  15. # Set message displayed on pow_detach (when HUP is sent to screen's parent
  16. # process).
  17. pow_detach_msg "BYE"
  18. # Default timeout to trigger an inactivity notify.
  19. silencewait 30 # default: 30
  20. # Change text highlighting. See http://bit.ly/11RDGZ
  21. sorendition gK
  22. # Do NOT display copyright notice on startup.
  23. startup_message off # default: on
  24. # Set $TERM for new windows. I have more luck with 'linux' than Terminal's
  25. # default 'xterm-color' (^H problems). Comment out to use the default.
  26. term linux
  27. # Tweak termcap, terminfo, and termcapinfo entries for best performance.
  28. termcap linux 'AF=\E[3%dm:AB=\E[4%dm'
  29. termcap xterm* 'AF=\E[3%dm:AB=\E[4%dm'
  30. terminfo linux 'AF=\E[3%p1%dm:AB=\E[4%p1%dm'
  31. terminfo xterm* 'AF=\E[3%p1%dm:AB=\E[4%p1%dm'
  32. # Allow xterm / Terminal scrollbars to access the scrollback buffer. This
  33. # enables the behavior you'd expect, instead of losing the content that scrolls
  34. # out of the window.
  35. termcapinfo linux ti@:te@
  36. termcapinfo xterm* ti@:te@
  37. # Use visual bell instead of audio bell.
  38. vbell off # default: ???
  39. # Message to be displayed when the visual bell is triggered.
  40. #vbell_msg " *beep* "
  41. # Get rid of screen 0
  42. # http://www.linuxquestions.org/questions/linux-software-2/gnu-screen-start-window-numbering-at-1-keep-window-number-0-from-ever-being-used-772580/
  43. bind c screen 1
  44. bind 0 select 10
  45. ##################################
  46. # Captions
  47. #
  48. # Control the display of the window captions.
  49. # Without the `always` option, captions will only show when there are multiple
  50. # windows.
  51. #
  52. # String Escapes, especially some Hard-to-Discover escapes, are described below.
  53. # For an age-old tool, screen documentation is not great.
  54. #
  55. # Great thanks to:
  56. # http://blog.quixey.com/2011/07/29/make-your-life-easier-with-gnu-screen/
  57. # http://aperiodic.net/screen/man:string_escapes
  58. # http://superuser.com/questions/212392/how-to-include-screens-session-name-in-hardstatus
  59. # http://superuser.com/questions/209585/adding-conditional-formatting-to-the-status-line-in-gnu-screen
  60. #
  61. # %{= kw} - clear existing format, set color to black/white background/foreground
  62. # %= - pad line with spaces to fill display width. In this case, centering can be
  63. # done by having `%=` on both the left and and right, as screen will
  64. # automatically make both paddings the same length.
  65. # More spacing and padding can be seen here:
  66. #
  67. # http://aperiodic.net/screen/truncation_padding_escapes
  68. #
  69. # I did not bother reading it.
  70. #
  71. # %-w - show windows smaller in number than the current
  72. # %+w - show windows greater in number than the current
  73. #
  74. # --- Note about the `L` flag ---
  75. # This was hard to catch in the docs.
  76. # Some screen escapes can be prefixed with 'L'.
  77. # For `%-Lw`, window flags are added to the window names,
  78. # For `%LD` and `%LM`, longer name are used
  79. #
  80. # %{+b} - add the bold attribute to the text
  81. # %n - window number
  82. # %t - window title
  83. # %f - window flags (for various states)
  84. # %?...%? - IF statement. Contents will only display if any ESCAPES produce at
  85. # least one char So, if `%f` resolves to nothing (i.e. there are no
  86. # other flags for this window), then nothing will be displayed.
  87. #
  88. # There is also an else, using `%:`, but I don't know how to use that.
  89. #
  90. caption always "%{= kw} %=%-Lw%{g}[%n* %t%? %f%?]%{= kw}%+Lw%="
  91. ##################################
  92. # Hardstatus Line
  93. #
  94. # Configure the use and emulation of the terminal's hardstatus line.
  95. # `lastline` will reserve the last line of the display for the hardstatus.
  96. # Prepending the word 'always' will force screen to use the type even if the
  97. # terminal supports a hardstatus line.
  98. #
  99. # Explanation of escapes
  100. #
  101. # %{k.} - change the background color. The `.` in place of the foreground
  102. # leaves the colour unchanged.
  103. # `%{.r}` would be redundant: single colours specified without other
  104. # modifiers are assumed to be foreground colour changes.
  105. #
  106. # Notice a space after this formatting - this is to force the following
  107. # padding escape to take the formatting. Otherwise, formatting will only
  108. # start from the next displayed character (the 'H' in 'Host:').
  109. #
  110. # %{+b r} - add bold, foreground red.
  111. # %{-} - special formatting escape saying, revert the last change to formatting
  112. # (in the first case, the adding of bold and red foreground)
  113. # %{y} - yellow foreground
  114. # %{m} - magenta foreground
  115. # %{b} - blue foreground
  116. # %H - Hostname
  117. # %1` - run `backtick` command with id = 1 (refer to below)
  118. # %u - other users in this window (surrounded by brackets)
  119. # %c - 24hr time
  120. # %LD - Long Day name (refer to L note above)
  121. # %d - day number
  122. # %m - month number
  123. # %Y - full year number
  124. #
  125. hardstatus alwayslastline "%{k.}%{y}Session: %{-}%{+b r}%?[%1`]%:[NoName]%? %{-}on %H%=%?%{-}Users: (%u)%?%=%{b}%c, %LD, %d.%m.%Y"
  126. msgwait 15
  127. ##################################
  128. # Backtick Commands
  129. #
  130. # Commands to call using the %` substitutions (e.g. in hardstatus line)
  131. # Potentially Very Powerful!
  132. # Note that any commands in backtick are expected to return only ONE line of
  133. # output (no idea what happens if there's more than that).
  134. #
  135. # Syntax:
  136. # backtick id lifespan autorefresh command [args...]
  137. #
  138. # id - number to use in substitution e.g. %2` would call backtick with id = 2
  139. # id = 0 is called simply with %`
  140. # lifespan - seconds to run command again
  141. # autorefresh - seconds to refresh caption and hardstatus text
  142. #
  143. # if both lifespan and autorefresh are 0, it is expected the command will
  144. # periodically produce a line of output. Once output is detected, hardstatus and
  145. # captions will refresh if necessary e.g. if command is a `tail -F`
  146. # get the sessionname that has been set by `C-a :sessionname` or by
  147. # `screen -S [name]`
  148. #
  149. backtick 1 30 30 sh -c 'screen -ls | grep --color=no -o "$PPID\.[^[:space:]]*" | sed s/$PPID\.// | sed s/ttys.*// | sed s/pts-.*//'
  150. ##################################
  151. # Default Windows
  152. #
  153. # In theory, you could use `chdir` before a `screen -t` to automate the changing
  154. # of directories, but I have found this troublesome if you just want screen for
  155. # other purposes (like performing Ubuntu release upgrades).
  156. #
  157. # Is there a way of toggling default windows on/off based on how we start
  158. # screen?
  159. #
  160. screen -t "home" 1