Print View

Setting Up .screenrc
Created: 09/24/2007


General Information

Messing with screen, making it work for you!

Requirements

None

Installation

As root (duh :P)
# cd /usr/ports/sysutilites/screen && make install clean

Configuration

All right once you install screen go back to using your normal user.  In your home dir do the following (whatever text editor you like):
$ vim .screenrc
There are a lot of options for your screenrc but for the most part these are the ones I have found to be useful.
#These are keybindings, you can also use the F1-F10 to map to specific screens
#F11 = previous screen | F12 = next screen
bindkey -k F2 next
bindkey -k F1 prev

startup_message off
nethack on
deflogin on
defscrollback 1000

# Optional name and command to execute
# These are great it will display all the screens rather than having to detach and the do 'screen -ls'
screen -t irssi 0
screen -t mail 1
screen -t news 2
screen -t notes 3
screen -t freebsd 4
screen -t unix 5
screen -t admin 6
screen -t systm 7
select 0 #This selects screen 0 (irssi) as the default screen when its started

# Display $USER and screen titles in a neat way :P
caption always "%{=b dy}{ %{= dm}${USER} %{=b dy}}%={ %?%{= dc}%-Lw%?%{+b dy}(%{-b r}%n:%t%{+b dy})%?(%u)%?%{-dc}%?%{= dc}%+Lw%? %{=b dy}}"
Well this is a very basic setup but it should get you started.  I personally love the keymapping cause pressing one key is a lot faster than pressing a combo, (not to mention it's easier to remember).

This guide is © 2007 - 2010 Patrick.

Author: Patrick
faustcoder at gmail dot com



1 Comment

Posted by vermaden on November 26, 2007 at 8:50:48 am EET

I would also add:

# general
autodetach on
vbell           off
shelltitle      sh

# enable SHIFT-PGUP / SHIFT-PGDOWN scroll
termcapinfo rxvt ti@:te@

# change window with ALT-Q and ALT-W
bindkey "^[q" prev
bindkey "^[w" next

# status // change first %{= M} --> %{= kM} to display status on black background
hardstatus alwayslastline '%{= M} %H%{= G} %l %= %{= w}%-w%{+b r}%n*%t%{-b r}%{w}%+w %= %{c}%d %D %{B}%c '


how does it looks:
http://vermaden.go.pl/gfx/shots/vermaden-2007.10.14.png

if you also want the status:
user: 1.5% | nice: 1.5% | system: 0.0% | interrupt: 0.0% | idle: 97.0%

add this to ~/.screenrc:
# add CPU idle/sustem/user/interrupt stats
backtick 100 5 5 tail -1 /var/tmp/vermaden-stats-top
caption always '%{= wk} %= %100` %='


and use uniload.sh script to generate /var/tmp/vermaden-stats-top:

#! /bin/sh

STATS_FILE=/var/tmp/vermaden-stats-top

bsd_top_stats () {
  top -s 1 -d 2 0
  | grep -m 1 CPU
  | tr -d ','    
| awk '{ print $4": "$3" | "$6": "$5" | "$8": "$7" | "$10": "$9" | "$12": "$11 }'
}

lin4_top_stats () {
  top -n 1      
  | grep -i cpu
  | head -1    
  | sed s/,//g  
  | awk '{ print $4": "$3" | "$6": "$5" | "$8": "$7" | "$10": "$9 }'
}

lin6_top_stats () {
  top -n 1      
  | grep -i cpu
  | head -1    
  | sed s/,//g  
  | awk '{ print $3": "$2" | "$5": "$4" | "$7": "$6" | "$9": "$8" | "$11": "$10" | "$13": "$12" | "$15": "$14 }'
}

case $( uname ) in
  FreeBSD) OS=bsd ;;
  Linux)   VERSION=$( uname -r | awk -F. '{ print $1"."$2 }' )
           case ${VERSION} in
             2.4) OS=lin4 ;;
             2.6) OS=lin6 ;;
               *) OS=lin4 ;;
           esac ;;
  *)       OS=bsd ;;
esac

while true; do
  for I in $( jot 128 ) ;do
    eval ${OS}_top_stats >> ${STATS_FILE} 2>&1
    sleep 4
  done
  sleep 1
  :> ${STATS_FILE}
done



Copyright 2003 - 2010 BSD Guides.  All rights reserved.

About | Terms of Use | Privacy | Contact