Thursday, August 09, 2007

screen: The power of windowing, in an xterm!

Here is an amazing piece of software, called screen, that will get you on a high if you spend just 5 minutes at it, exploring it with the help of a nicely prepared tutorial (here). It came pre-installed with my Ubuntu 7.04 (Feisty), but can be easily downloaded and installed.

Some of the things it can do for you:
  1. Allow you to open 'virtual' terminal windows inside a single xterm: not gnome-terminal, not konsole, just plain and simple xterm!
    So you can open various screen-based applications without opening so many independent terminals. That helps avoid clutter in the taskbar as well as saves you the hassle of searching for a particular terminal window. Switching between each of those virtual terminals is extremely easy, by the way.

  2. It also lets you run applications and then close (not always, it is all as you wish) the window that spawned the application, without disrupting the progress of the spawned process. As good as, if not better than, nohup.
    This is the main reason that led me to discover this highly useful piece of software, that remains to be highly under-used and is in fact unknown to linux users at large. Sad, I say!

  3. Has it ever happened with you that you opened a set of terminals, started doing some work in each of them but you had to leave the place in the middle of your job and then login from another machine? How do you get back those terminals? VNC? But why waste so much bandwidth when the same can be done safely and easily using screen. It lets you start a session of 'virtual' terminals, each of them running any application (totally independent of other applications). Then, if you have to leave the current place, just inform screen about the same and all will be taken care of!

It can do a lot more things, like the ability to let you work collaboratively with someone else, the ability to name (and rename) terminals, the ability to monitor terminals for activity, and so on and so forth.

Here are some of my settings.
  1. ${HOME}/.screenrc:
    #change the hardstatus settings to give an window list at the bottom of the                                              
    #screen, with the time and date and with the current window highlighted
    startup_message off
    defscrollback 2048
    vbell off
    altscreen on
    hardstatus alwayslastline
    backtick 1 60 60 /home/varunk/.screen_ip
    hardstatus string '%{gk}[%{G}%H: %1`%{g}][%= %{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}][%{Y}
    shelltitle "$\ |term"
  2. ${HOME}/.screen_ip:
    #!/bin/bash
    # Script to get run by hardstatus in screen.
    # Prints customized single-line system stats
    IP=`ifconfig eth0 | grep Mask | cut -d: -f2 | cut -d " " -f1`
    UP=`uptime | awk -F' |,' '{print $4" "$5", "$8}'`
    echo -n "$IP | UP: $UP"
  3. Screenshot of my screen:
Give it a try and let me know if you do not like a thing about it.

Labels: , , , , , , ,

0 Comments:

Post a Comment

<< Home