June 21, 2018

Ubuntu-ized GNU Screen is Faster and Friendlier - page 2

A Short Tutorial

  • June 1, 2009
  • By Charlie Schluting

Ubuntu's screen ships with wrapper scripts that prompt you to select a theme the first time screen is run. You may never notice these sorts of changes if you always drag your old home directory along everywhere you go.

If you select ubuntu-dark as the theme, you end up with a few small, but very significant changes to your screen environment. Your ~/screen-profiles/profile will be symlinked to /usr/share/screen-profiles/profiles/ubuntu-dark. This file holds the key to all the magic.

To explain what we're gushing about, run screen and select ubuntu-dark. You will notice two permanent bars on the bottom. The first lists your current windows, and the second lists vital information about the host you're running screen on. The bottom line includes uptime, load average, cpu frequency, total and available RAM, and the time (which constantly updates). Of course you can add other things, this is just the Ubuntu default.

To replicate the first bar across the bottom on your non-Ubuntu system, enter the following in your ~/.screenrc file:

caption always "%{wK}%?%-Lw%?%{bw}%n*%f %t%?(%u)%?%{wK}%?%+Lw%? %= %{= Kw}%110`%109`%111`"

A caption in screen is just what it sounds like. The caption will be the bottom line (until we do something else to make it the second to last) in your terminal window. The escape sequences above are what Ubuntu uses, and you're free to adjust as necessary.

Finally, the very last line is called the hardstatus. This is actually a function of your terminal, which will keep the last line separate from your normal input/output space. If the terminal type you're using does not support hardstatus, screen will fake it by using the last line in the terminal to display this information.

To set it as described above, add this to your .screenrc:

hardstatus string '%99`%{= Kw} %100`%112`%= %102`%101`%114`%115`%108`%113`%119`%117`%118`%116`%106`%104`%103`%105`%107`%Y-%m-%d %0c:%s'

Unfortunately, this will only work in Debian-based systems that have the screen-profiles package installed. To get this functionality on other systems, you would need to get screen-profiles installed and working. The commands above such as '110 are defined by this package, and while you could replicate this functionality, it would probably be easiest to attempt porting the Debian package to other systems.

We find these settings useful for two reasons. First, the hardstatus bar is very handy for getting a quick status overview of your system. You can easily tell is the load is high or if you're in a dire memory situation. Second, it unmistakably lets you know that you're in a screen session, without requiring that you attempt running screen commands to check.

When he's not writing for Enterprise Networking Planet or riding his motorcycle, Charlie Schluting is the Associate Director of Computing Infrastructure at Portland State University. Charlie also operates OmniTraining.net, and recently finished Network Ninja, a must-read for every network engineer.

Article courtesy of Enterprise Networking Planet

Most Popular LinuxPlanet Stories

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.