solairis.com

GNU Screen Notes

Screen with tabs and split This is a cheat sheet of GNU Screen stuff I use often.

TOC

Note: ^ is used to denote the "screen command character." If you use the .screenrc below then the command character is `, otherwise it is Ctrl+a.

screenrc ^

escape `` # Change escape to `                                                                                                                                   

hardstatus alwayslastline

hardstatus string '%{= mK}%-Lw%{= KW}%50>%n%f* %t%{= mK}%+Lw%< %{= kG}%-=%D %d %M %Y %c:%s%{-}'
# I'll do without the time. Thank you very much.
#hardstatus string '%{= mK}%-Lw%{= KW}%50>%n%f* %t%{= mK}%+Lw%<'

Command Line ^

From the command line screen will start, and put you in, a new screen session. You can detach with ^d. screen -ls will show your screens and their status'. screen -r will re-attach you to the screen you just closed. screen -S coolname will create a screen called "coolname". This is handy if you have many screen sessions. You can then re-attach to this particular one by doing screen -r coolname.

screen -d will detach a screen elsewhere (good for when you left work but forgot to detach your screen). Add -r to then attach to that screen.

Screen Commands ^

  • ^d: Detach from screen session.
  • ^c: Create a new window.
  • ^A: Name your current window.
  • ^": Show a list of all windows from which you can select the one you want.
  • ^n and ^p: flip through your windows.
  • ^S: Split your screen (beware ^s [that's lowercase "s"]!).
  • ^+ and ^-: resize your current split. You can also do ^:resize 20 to set to a specific row height or ^:resize +5 to increase it by that many rows.
  • ^<TAB> Move between screen splits.

Gotchas ^

^s is the same as sending a ctrl s to the window. Which stops output to the screen. It will appear that the window has frozen. To resume output you need to send a ctrl q to the window which is accomplished by ^q.

The reason for this is one of the side effects of how screen works. Input is sent to the terminal, then to screen, then screen sends it to the window. Typing ctrl s in screen will cause output to stop to the entire terminal; You won't see the time change (if you've enabled that in .screenrc), if something is outputting like a tailed log you won't see it, you won't even see windows change if you cycle through them or resize them. Though it's still happening the output to your terminal has been supressed. When you send a ^s screen intercepts it and sends a ctrl s to the window itself. Now just output to that window has stopped; time will still move, you can still change and do things in other windows and you can still detach from your screen session. ^q will tell screen to send the ctrl q signal to that window and resume output.