Weblog entry #1 for lindenle

Bending screen to my will
Posted by lindenle on Sat 23 Jun 2007 at 14:24
Tags: none.
Screen is my new favorite utility for Linux administration, but I found that I wanted it to behave a bit differently. Specifically I wanted the window list to show the directory and command being run in each pseudo terminal.

1. First get the bash prexec utility.

2. Then I added the following to my .bashrc


if  [ -f ${HOME}/bin/preexec.bash ]  &&  [ "$TERM" == "screen" ] ; then
    . ${HOME}/bin/preexec.bash
    function set_screen_title () {
        local title="$1"
        echo -ne '\ek'${1}'\e\\'
    }
    function precmd () {
        set_screen_title "$1"
    }
    
    function preexec () {
        set_screen_title "$1"
    }

    preexec_install
fi



Now when I run screen it lists the full command of what I am running
as the screen name. Sweet!

 

Comments on this Entry

Posted by Anonymous (219.95.xx.xx) on Mon 25 Jun 2007 at 04:49
i use screen too.

i use the screen name, that appears at the bottom, to know which screen i'm at.

in your case, how does setting the screen name to the executed command really help you? what does it do for you?

[ Parent | Reply to this comment ]

Posted by lindenle (192.76.xx.xx) on Tue 26 Jun 2007 at 10:20
[ Send Message | View Weblogs ]

I often have many connections to many machines and using this utility I can see the machine and the command I am running. Here is an example where I am logged into my mail server watching some logs and also to remote host. Here is what the screen list looks like:

Num  Name                            Flags
 0  {@spike lindenle}: uprecords -f                     $
 1  {@spike lindenle}: htop                             $
 2  {@spike lindenle}: mutt                             $
 3  {@one lindenle}:  top                               $
 4  {@spike lindenle}: sudo tail -f /var/log/mail.log   $
 5  {@spike lindenle}:                                  $
 6  {@localhost lindenle}:                              $

The other major advantage is not closing your session when you log out. For me this is a must because i do all my analysis on a remote computer cluster with only terminal access. In fact it has been a life saver a few times recently when working from hotels with flaky wireless connections, even when the network goes down and ssh connection hangs I can just log back in and reconnect to my screen session(s).

[ Parent | Reply to this comment ]

Posted by Steve (80.68.xx.xx) on Tue 26 Jun 2007 at 10:53
[ Send Message | View Steve's Scratchpad | View Weblogs ]

Your entries would look better if you stopped using "&nbsp;" tags everywhere and just used <pre> like everybody else.

Steve

[ Parent | Reply to this comment ]

Posted by lindenle (192.76.xx.xx) on Tue 26 Jun 2007 at 13:52
[ Send Message | View Weblogs ]
I have no idea how i put that in there ;). I just pasted it in and hit reply. Can I edit it to make it look better?

[ Parent | Reply to this comment ]

Posted by Steve (80.68.xx.xx) on Tue 26 Jun 2007 at 13:55
[ Send Message | View Steve's Scratchpad | View Weblogs ]

I'm afraid not. Comments are deliberately non-editble. If you like I can fix that one for you, but in general only articles, weblogs and polls are editable.

Steve

[ Parent | Reply to this comment ]

Posted by lindenle (192.76.xx.xx) on Tue 26 Jun 2007 at 14:10
[ Send Message | View Weblogs ]
I would really appreciate it if you fixed it. I would like the code area to look like the articles do i.e. with the grey background. I am using bbcode with "[code]" tags but that does not seem to work. Could you tell me how to do this correctly?

Thanks

[ Parent | Reply to this comment ]

Posted by Steve (80.68.xx.xx) on Tue 26 Jun 2007 at 14:27
[ Send Message | View Steve's Scratchpad | View Weblogs ]

You should be able to use "[pre]" + "[/pre]" to surround text. That will give it the same styling as the <pre> in HTML.

Steve

[ Parent | Reply to this comment ]

Posted by oxtan (82.95.xx.xx) on Thu 28 Jun 2007 at 05:23
[ Send Message | View Weblogs ]
your link to the bash prexec thingie points to your own weblink entry; is this the intention?

what is this 'bash prexec' anyway? I am unable to find any information about it on the web.

[ Parent | Reply to this comment ]

User Login

Username:

Password:

[ Advanced Login ]

Register Account

Quick Site Search