View previous topic :: View next topic |
Author |
Message |
karneevor n00b
Joined: 10 Dec 2003 Posts: 47 Location: Denmark
|
Posted: Sun Jul 23, 2006 1:15 pm Post subject: Automatically start of screen |
|
|
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.
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 |
|
|
mudrii l33t
Joined: 26 Jun 2003 Posts: 789 Location: Singapore
|
Posted: Sun Jul 23, 2006 4:39 pm Post subject: |
|
|
Nice script I will try it
Thx _________________ www.gentoo.ro |
|
Back to top |
|
|
vandalman n00b
Joined: 16 Mar 2005 Posts: 52
|
Posted: Tue Jul 25, 2006 7:26 am Post subject: |
|
|
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 |
|
|
pi-cubic Tux's lil' helper
Joined: 25 May 2003 Posts: 143
|
Posted: Tue Jul 25, 2006 2:27 pm Post subject: |
|
|
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 |
|
|
opentaka l33t
Joined: 18 Feb 2005 Posts: 840 Location: Japan
|
Posted: Wed Jul 26, 2006 12:49 pm Post subject: |
|
|
oh cool!
thanks _________________ "Being defeated is often a temporary condition. Giving up is what makes it permanent" - Marilyn vos Savant
|
|
Back to top |
|
|
|