HomeAWSAzureGCPIBMToolsAboutcontact Us

Screen 201: 7 Ways to Change Your View When Using Screen

Posted On March 26th, 2018

Discussing Tools

In a previous post I detailed the basic usage of GNU Screen. Below I will cover how to customize screen to make it easier to use and more convenient for you. If you’ve used screen at all you know out-of-the-box it can be a bit plain and quirky. In fact, it’s virtually impossible to distinguish a screen virtual terminal from your standard SSH or terminal window. Not to worry because there is plenty of power under the hood of screen to make it work for you! Not a Linux user? That’s fine, keep reading! Since Mac OSX is based on FreeBSD (a Linux cousin) Screen will work for you as well! And if you run Windows but SSH to Linux or Mac servers you can still use screen once connected to protect your sessions should you lose Internet connectivity. What does this really do for me? Screen allows you close your terminal window and resume your session without starting over. I typically will start a screen session at home so when I get to the office I can reattach to that session and pickup where I left off without losing any work or forgetting where I was or what I was doing. Similarly, many admins use screen to start work and then let a co-worker attach to the session so they can pickup where you left off. So, how can you customize how screen behaves for you? Here are 7 ways to improve your screen experience:
  1. When you first start screen it is not uncommon to see a copyright notice. If you use screen a lot this can get quite annoying. You can easily turn this message off by adding the following:
    startup_message off
    
     
  2. Ensure your work does not get interrupted should the remote system try to “beep” at you. Over screen this would give you a visual message that we can do without:
    vbell off
    
     
  3. Defaults on various servers may differ, so you want to be sure your screen session does not terminated if you lose your connection with:
    autodetach on
    
     
  4. There are some shell apps like less and vi that can cause your display to become unreadable through screen. This option will help keep your session usable:
    altscreen on
    
     
  5. By default screen will only give you 100 lines of scroll buffer as history. I like to be able to see a LOT of data that may have scrolled off my display, especially if reviewing log files or the like. I get 100,000 lines of scrollback buffer with:
    defscrollback 100000
    
     
  6. Out of the box, screen will not allow you to scroll back through your buffer, once data leaves your viewable screen the data is gone. As you can tell above this does not sit well with me so I use this to allow the scrolling I expect to see:
    termcapinfo xterm* ti@:te@
    
     
  7. Lastly, I want to know with certainty that I am using a screen session and get usable information at the same time. This will add a bar to the bottom line of your session with machine hostname, system load info, date, and time:
    hardstatus on
    hardstatus alwayslastline
    hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} [%{r}%l%{w}] %m/%d/%Y %C%A "
    
     
Put it all together for a great finished product. SSH to your server and in your home directory add a file named .screenrc and paste the full set of options to the file and save it.
startup_message off # Prevent the screen copyright info from displaying
vbell off # Disable the visual bell
autodetach on # Make sure set to 'on' so session is not terminated upon hangup
altscreen on # Helps keep display usable after some shell apps exit (like less and vi)
defscrollback 100000 # Get more than the standard 100 lines

termcapinfo xterm* ti@:te@ # Disable alternate text butter so scroll works in cat, vi, etc.

# Enable and define what our status line will look like
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} [%{r}%l%{w}] %m/%d/%Y %C%A "
The next time you launch a new virtual terminal with screen you will see the difference. Prepare yourself for my "screen" capture: Screen Capture Here's a little better look at the bottom line: Do you use screen or love another tool that makes your life easier? I’d love to hear about it in the comments below!
Tags: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

© Copyright 2018 - Lane Vance - All Rights Reserved. Logos and Trademarks copyright their respective owners.
HomeAWS
AzureGCPIBMToolsAboutContact Us
facebook-squaretwitterfacebooklinkedinmenu