screenrc 7.8 KB

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