.screenrc configuration
on January 07, 2007 @ 02:14 AM
I spend most of my time in screen when I’m coding or doing any system administration work. It gives me the ability to do multiple things in a single window, and never have to remove my hands from my keyboard to switch terminal sessions or split windows. It even provides the flexibility of detaching and reattaching to screen sessions while leaving your terminal sessions in existence.
I’ve been using the below .screenrc file recently to give me some more useful information.
The screenshot
Note the following things in the screenshot:- system hostname
- system ip addresses for each interface configured (see below “whatsmyip” file information)
- system load (updates every few seconds)
- date
- current time (this updates every second)
The .screenrc file
altscreen on
hardstatus on
hardstatus alwayslastline
backtick 1 60 60 /home/zdennis/bin/whatsmyip
hardstatus string "%-Lw %{= kG}Host: %{Y}%H%? %{c}(%1`) \
%{= kG} %-=Load: %{Y}%l%{kG} %{= kG}Date: %{Y}%m/%d\
/%y%{= kG} Time: %{Y}%C:%s%a%{= kG}%{W}"
caption always
caption string "%-Lw%{= bw}%50>%n %t%{-}%+Lw%<"
Note: The lines that end in \ note a continuation of the line.
The whatsmyip file
The whatsmyip file is a simple ruby script which parses out all interfaces configured with an ip address.
1 2 3 4 5 6 7 8 9 |
#!/usr/bin/ruby interfaces = `ifconfig`.scan( /^(\w+)/ ).flatten.delete_if{ |interface| interface =~ /lo/ } arr = interfaces.inject( [] ) do |arr,interface| md = `ifconfig #{interface}`.match( /((\d+\.){3}\d+)/ ) arr << "#{interface}: #{md.captures.first}" if md arr end print arr.join( ' ' ) |


2 comments
Jump to comment form | comments rss [?]