Guest User

Untitled

a guest
Apr 23rd, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.69 KB | None | 0 0
  1. GNUScreen
  2. ---------
  3.  
  4. Screen is to the console what your window manager is to X. It will allow you to have several
  5. buffers or windows running at the same time, you can easily switch from one buffer to another,
  6. copy and paste between them, create new windows and close others, etc. Each new window will
  7. launch a new process defined by the configuration, typically an interactive shell. But that is
  8. not all. Probably the better feature is that it runs as a separated process from the X server,
  9. though, you can get connected to it from a Terminal window running on top of X. We will return
  10. to this topic later.
  11.  
  12. Now we'll going to do a tour though most useful screen features, from basic ones to some cute
  13. configurations that can make your life easier understanding screen.
  14.  
  15. Launching Screen
  16. ----------------
  17.  
  18. This one is easy, from a console type "screen" (without quotes) and press enter. This is a way
  19. to launch screen, we will see later we can do some cool stuff using the screen command, but for
  20. now, this is the basic way to start screen.
  21.  
  22. Basic usage
  23. -----------
  24.  
  25. First some conventions, as many Unix manuals, <c-X> stands for a keyboard shortcut using the
  26. CONTROL key and the "X" key.
  27. The way to communicate with screen is typing a prefix -<c-a> by default- and then pressing a
  28. key.
  29.  
  30. <c-a> c -> *C*reates a new *C*onsole window
  31. <c-a> n -> *N*ext tab or window
  32. <c-a> <space> -> next tab
  33. <c-a> <Return> -> next tab
  34. <c-a> p -> *P*revious tab
  35. <c-a> S -> *S*plit screen
  36. <c-a> <Tab> -> focus next frame
  37. <c-a> Q -> make current frame the only one
  38. <c-a> K -> **K**ill current application
  39. <c-a> ? -> Shows all commands (really helpful)
  40. <c-a> w -> Shows a list of current running tabs
  41.  
  42. Those are the basics keys used by navigate through the different "tabs" or "windows". They are
  43. pretty easy to use. Suppose you are downloading something with wget. It is boring to watch the
  44. download progress, so you want to do something else. Press <c-a> c to create a new terminal and
  45. launch whatever you want from there. If you want to check the download, just press <c-a> p to go
  46. to the previous tab, and <c-a> n to back to your funny stuff. You can use this features in TUI
  47. mode, or in GUI mode from a terminal window as well.
  48.  
  49.  
  50. Detaching and reattaching
  51. --------------------------
  52.  
  53. One of greatest screen's feature is the ability to detach itself from the current terminal
  54. application that's running in (xterm, putty or whatever). We said already Screen runs as a
  55. separated process from X, this is why that is so great. If you want to restart the X server, or
  56. some X application makes it to crash, all the programs and processes running on Screen will keep
  57. going. If you are working over a ssh connection and you suddenly suffer network problems, the
  58. processes you started from Screen over ssh will keep going too. If you have no problem at all
  59. but for some reason you want to detach your terminal and reattach it from another place, Screen
  60. will let you do it.
  61. We can see an example, the usual work flow when using ssh should be:
  62.  
  63. Connect to the remote machine (using ssh, putty,...). Then start a screen session. Open as many
  64. consoles as you want. If your connection falls, normally you would loose all unsaved changes and
  65. current processes would be killed in a rude way. Not to talk if you were compiling/executing
  66. something that would last several hours...So much work lost!
  67.  
  68. That's what you could think at first, but screen has a very powerful feature
  69. called 'detach'. When something goes wrong with your connection, or you click
  70. that 'X' at the corner window, screen just detaches itself from the containing
  71. window, but none of your work is lost. It keeps running at the background. you
  72. can try playing some music with mplayer, and closing the terminal containing it
  73. and keep listening music.
  74.  
  75. When you're on a system without X, and you have no 'x' to click (or nested
  76. screens), you can detach screen with the next command:
  77.  
  78. <c-a> d -> *d*etach screen
  79.  
  80. Now if you want to recover (reattach) your screen session you just open a
  81. terminal and enter the command:
  82.  
  83. screen -r
  84.  
  85. I personally use screen -DR that forces a reattach and it even detaches it if
  86. it was active somewhere else.
  87.  
  88. If you have more than one screen detached, you have to provide info about
  89. which screen session you want to recover.
  90.  
  91. kidd@raymobil [ ~ ] %screen -ls
  92. There are screens on:
  93. 2945.pts-0.raymobil (Attached)
  94. 1558.pts-8.raymobil (Detached)
  95. 2 Sockets in /tmp/uscreens/S-kidd.
  96.  
  97. Then you can decide which one you want.
  98.  
  99. screen -r 29
  100.  
  101. will do the job. (unique substring)
  102.  
  103. Multiuser
  104. ---------
  105.  
  106. screen -x pid
  107.  
  108. copy mode
  109. ---------
  110.  
  111. With screen you can copy and paste text between buffers in the same session.
  112. It's done only with the keyboard (pretty useful if you have to paste text from
  113. a terminal to an IRC channel to get help on how to recover your X).
  114.  
  115. <c-a> <esc> -> enters 'copy mode'.
  116.  
  117. Once in copy mode, you can move around your window with hjkl (vi movement keys), arrow keys, or
  118. page-up and page-down. Once in copy mode, press <space> to start the selection. Use the movement
  119. keys to select the desired text and press <space> again to exit the selection mode. Now you
  120. have the text copied and ready to be pasted where you want.
  121.  
  122. <c-a> ] pastes the copied text onto current buffer.
  123.  
  124. screen provides a way so search text in the scroll buffer, guess what? it's the
  125. vi style ;)
  126.  
  127. c-a <esc> ?text<Return>
  128.  
  129. options, binds and beautifying
  130. ------------------------------
  131.  
  132.  
  133. .screenrc
  134. ---------
  135.  
  136. making screen collaborate with other apps
  137. -----------------------------------------
  138.  
  139. Making zsh set titles dynamically
Add Comment
Please, Sign In to add comment