Re: [gentoo-user] dog - man's best friend.

2012-02-23 Thread Alan Mackenzie
Hi, Paul.

On Thu, Feb 23, 2012 at 03:37:34PM -0600, Paul Hartman wrote:
> On Thu, Feb 23, 2012 at 3:32 PM, Paul Hartman
>  wrote:
> > On Thu, Feb 23, 2012 at 2:42 PM, Alan Mackenzie  wrote:
> >> I've finally been pushed over the edge.  I simply can't stand it any
> >> longer.  The "it" in this case is viewing a file or process output and
> >> either: (a) using less, and have it take just 10 screen lines; (b) using
> >> cat etc., and have the interesting part scroll away.

> > You should just alias less to "less -E", it does exactly what you invented. 
> > :)
 
> Oops, typo, I meant -F not -E. :)

Well, that's one way of discovering new features in familiar software.
;-)

Thanks!

-- 
Alan Mackenzie (Nuremberg, Germany).



Re: [gentoo-user] dog - man's best friend.

2012-02-23 Thread Paul Hartman
On Thu, Feb 23, 2012 at 3:32 PM, Paul Hartman
 wrote:
> On Thu, Feb 23, 2012 at 2:42 PM, Alan Mackenzie  wrote:
>> I've finally been pushed over the edge.  I simply can't stand it any
>> longer.  The "it" in this case is viewing a file or process output and
>> either: (a) using less, and have it take just 10 screen lines; (b) using
>> cat etc., and have the interesting part scroll away.
>
> You should just alias less to "less -E", it does exactly what you invented. :)

Oops, typo, I meant -F not -E. :)



Re: [gentoo-user] dog - man's best friend.

2012-02-23 Thread Paul Hartman
On Thu, Feb 23, 2012 at 2:42 PM, Alan Mackenzie  wrote:
> I've finally been pushed over the edge.  I simply can't stand it any
> longer.  The "it" in this case is viewing a file or process output and
> either: (a) using less, and have it take just 10 screen lines; (b) using
> cat etc., and have the interesting part scroll away.

You should just alias less to "less -E", it does exactly what you invented. :)



Re: [gentoo-user] dog - man's best friend.

2012-02-23 Thread Kevin Monceaux
On Thu, Feb 23, 2012 at 08:42:00PM +, Alan Mackenzie wrote:
  
> (a) using less, and have it take just 10 screen lines; (b) using cat etc.,
> and have the interesting part scroll away.

(c) use less -F and less will automatically exit if the entire file can fit
on one screen.  One can export LESS='-F' to have less always do the above.



-- 

Kevin
http://www.RawFedDogs.net
http://www.WacoAgilityGroup.org
Bruceville, TX

What's the definition of a legacy system?  One that works! 
Errare humanum est, ignoscere caninum.



Re: [gentoo-user] dog - man's best friend.

2012-02-23 Thread Neil Bothwick
On Thu, 23 Feb 2012 20:42:00 +, Alan Mackenzie wrote:

If the subject is true, why does your dog have no man page?

> I've finally been pushed over the edge.  I simply can't stand it any
> longer.  The "it" in this case is viewing a file or process output and
> either: (a) using less, and have it take just 10 screen lines; (b) using
> cat etc., and have the interesting part scroll away.
> 
> To solve this dilemma, I've written dog, a short script that will splat
> lines to the screen if they're few enough, invoke less otherwise. 

% eix -e dog
[I] sys-apps/dog
 Available versions:  1.7-r4{tbz2}
 Installed versions:  1.7-r4{tbz2}(15:54:25 20/12/11)
 Homepage:http://packages.gentoo.org/package/sys-apps/dog
 Description: Dog is better than cat

-- 
Neil Bothwick

Top Oxymorons Number 27: Military Intelligence


signature.asc
Description: PGP signature


[gentoo-user] dog - man's best friend.

2012-02-23 Thread Alan Mackenzie
Hi, Gentoo!

I've finally been pushed over the edge.  I simply can't stand it any
longer.  The "it" in this case is viewing a file or process output and
either: (a) using less, and have it take just 10 screen lines; (b) using
cat etc., and have the interesting part scroll away.

To solve this dilemma, I've written dog, a short script that will splat
lines to the screen if they're few enough, invoke less otherwise.  I've
set the threshold between the two cases at 60 lines.  If your screen is
a different size, change the two obvious bits.

Enjoy!

dog:
#

#!/bin/bash
export IFS=""
lin=0
while [ $lin -lt 60 ] && read ; do
buf[$lin]=$REPLY
lin=$((lin + 1))
done

if [ $lin -ge 60 ] ; then
(
for (( i = 0 ; i < 60 ; i++ )) ; do
echo ${buf[$i]}
done
while read ; do
echo $REPLY
done
) | less
else
for (( i = 0 ; i < $lin ; i++ )) ; do
echo ${buf[$i]}
done
fi

#

-- 
Alan Mackenzie (Nuremberg, Germany).