Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Automatically start of screen
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
karneevor
n00b
n00b


Joined: 10 Dec 2003
Posts: 47
Location: Denmark

PostPosted: Sun Jul 23, 2006 1:15 pm    Post subject: Automatically start of screen Reply with quote

Hi out there.

It's amazing that I had to wait for some years before I learned about the little smart program called screen. Sadly enough, I often forgot to start it when I entered a new bash session. So I wrote me a little program to help starting screen.

Put it in the last line of your .bashrc.

I want to share it with all you guru's. :wink:

Code:

#!/bin/bash
ps -ef > /tmp/top.tmp
CPID=$$
LOOP=1
a=1
ISSCREENSTARTED=0
while [ "$LOOP" -eq "1" ]
  do
  GREPLINE="^[a-z0-9]*[[:space:]]+$CPID"
  PIDLINE=`egrep $GREPLINE /tmp/top.tmp`
  ISSCREEN=`echo "$PIDLINE" | grep " screen" | wc -l`
  CUSER=`echo $PIDLINE| awk '{print $1}'`
  if [ $CUSER == $USER ]
      then
      if [ "$ISSCREEN" -eq "$a" ]
          then
          ISSCREENSTARTED=1
          LOOP=0
      fi
      CPPID=`echo $PIDLINE| awk '{print $3}'`
      if [ "$CPPID" == "1" ]
          then
          LOOP=0
      fi
  else
      LOOP=0
  fi
  CPID=$CPPID
done
if [ $ISSCREENSTARTED == "0" ]
    then
    echo "Do you NOT want to start screen? Press a letter to cancel screen."
    TIMELIMIT=2
    read -t $TIMELIMIT variable
    if [ -z "$variable" ]  # Is null?
        then
        echo "Timed out, no input yet."
        screen
    else
        echo "Not starting screen"
    fi
fi


If you don't like to copy and paste please use the link here to download the file:
http://provingground.dk/tiki-download_file.php?fileId=15

Any comments are welcome.
_________________
Kind regards.

Karneevor
Denmark

"I'm really not interested in public opinion polls on my tactical decisions" - Admiral Tolwyn
Back to top
View user's profile Send private message
mudrii
l33t
l33t


Joined: 26 Jun 2003
Posts: 789
Location: Singapore

PostPosted: Sun Jul 23, 2006 4:39 pm    Post subject: Reply with quote

Nice script I will try it
Thx
_________________
www.gentoo.ro
Back to top
View user's profile Send private message
vandalman
n00b
n00b


Joined: 16 Mar 2005
Posts: 52

PostPosted: Tue Jul 25, 2006 7:26 am    Post subject: Reply with quote

I turn hardstatus on so that I get a status bar at the bottom of the terminal. It's like a tab view and it is a good reminder when screen is started. Add this to your .screenrc:

Code:
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rW}%n %t%{-}%+w %=%{..G} %H %{..Y} %m/%d %C%a"
Back to top
View user's profile Send private message
pi-cubic
Tux's lil' helper
Tux's lil' helper


Joined: 25 May 2003
Posts: 143

PostPosted: Tue Jul 25, 2006 2:27 pm    Post subject: Reply with quote

here's another fancy hardstatus line. It includes current load and the time:
Code:
hardstatus alwayslastline "%{= kr}%?%-Lw%?%{= kc}%n*%f %t%?(%u)%?%{= kr}%?%+Lw%?  %=%{= kR}|%{= kc}%l%{= kR}|%{= kc}%c:%s%{= kR}|


looks like this:
Code:
0 zsh:~  1 zsh:~  2 zsh:~  8- zsh:~  9* zsh:~                                  |0.02 0.12 0.14|16:26:16|


have fun,

pi3
Back to top
View user's profile Send private message
opentaka
l33t
l33t


Joined: 18 Feb 2005
Posts: 840
Location: Japan

PostPosted: Wed Jul 26, 2006 12:49 pm    Post subject: Reply with quote

oh cool!

thanks :)
_________________
"Being defeated is often a temporary condition. Giving up is what makes it permanent" - Marilyn vos Savant
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum