* [gentoo-user] dog - man's best friend.
@ 2012-02-23 20:42 Alan Mackenzie
2012-02-23 20:52 ` [gentoo-user] " Nikos Chantziaras
` (3 more replies)
0 siblings, 4 replies; 12+ messages in thread
From: Alan Mackenzie @ 2012-02-23 20:42 UTC (permalink / raw
To: gentoo-user
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).
^ permalink raw reply [flat|nested] 12+ messages in thread
* [gentoo-user] Re: dog - man's best friend.
2012-02-23 20:42 [gentoo-user] dog - man's best friend Alan Mackenzie
@ 2012-02-23 20:52 ` Nikos Chantziaras
2012-02-23 20:58 ` [gentoo-user] " Neil Bothwick
` (2 subsequent siblings)
3 siblings, 0 replies; 12+ messages in thread
From: Nikos Chantziaras @ 2012-02-23 20:52 UTC (permalink / raw
To: gentoo-user
On 23/02/12 22:42, Alan Mackenzie wrote:
> I've
> set the threshold between the two cases at 60 lines. If your screen is
> a different size, change the two obvious bits.
You can use the $LINES env variable to get the height of the current
terminal. Another way to get them is with the "tput" command. "tput
lines" and "tput cols" print the amount of lines and columns on stdout.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] dog - man's best friend.
2012-02-23 20:42 [gentoo-user] dog - man's best friend Alan Mackenzie
2012-02-23 20:52 ` [gentoo-user] " Nikos Chantziaras
@ 2012-02-23 20:58 ` Neil Bothwick
2012-02-23 21:28 ` Kevin Monceaux
2012-02-23 21:32 ` [gentoo-user] " Paul Hartman
3 siblings, 0 replies; 12+ messages in thread
From: Neil Bothwick @ 2012-02-23 20:58 UTC (permalink / raw
To: gentoo-user
[-- Attachment #1: Type: text/plain, Size: 881 bytes --]
On Thu, 23 Feb 2012 20:42:00 +0000, 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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] dog - man's best friend.
2012-02-23 20:42 [gentoo-user] dog - man's best friend Alan Mackenzie
2012-02-23 20:52 ` [gentoo-user] " Nikos Chantziaras
2012-02-23 20:58 ` [gentoo-user] " Neil Bothwick
@ 2012-02-23 21:28 ` Kevin Monceaux
2012-02-23 23:24 ` [gentoo-user] " Harry Putnam
2012-02-23 21:32 ` [gentoo-user] " Paul Hartman
3 siblings, 1 reply; 12+ messages in thread
From: Kevin Monceaux @ 2012-02-23 21:28 UTC (permalink / raw
To: Gentoo User Mailing List
On Thu, Feb 23, 2012 at 08:42:00PM +0000, 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.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] dog - man's best friend.
2012-02-23 20:42 [gentoo-user] dog - man's best friend Alan Mackenzie
` (2 preceding siblings ...)
2012-02-23 21:28 ` Kevin Monceaux
@ 2012-02-23 21:32 ` Paul Hartman
2012-02-23 21:37 ` Paul Hartman
3 siblings, 1 reply; 12+ messages in thread
From: Paul Hartman @ 2012-02-23 21:32 UTC (permalink / raw
To: gentoo-user
On Thu, Feb 23, 2012 at 2:42 PM, Alan Mackenzie <acm@muc.de> 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. :)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] dog - man's best friend.
2012-02-23 21:32 ` [gentoo-user] " Paul Hartman
@ 2012-02-23 21:37 ` Paul Hartman
2012-02-23 21:58 ` Alan Mackenzie
0 siblings, 1 reply; 12+ messages in thread
From: Paul Hartman @ 2012-02-23 21:37 UTC (permalink / raw
To: gentoo-user
On Thu, Feb 23, 2012 at 3:32 PM, Paul Hartman
<paul.hartman+gentoo@gmail.com> wrote:
> On Thu, Feb 23, 2012 at 2:42 PM, Alan Mackenzie <acm@muc.de> 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. :)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] dog - man's best friend.
2012-02-23 21:37 ` Paul Hartman
@ 2012-02-23 21:58 ` Alan Mackenzie
0 siblings, 0 replies; 12+ messages in thread
From: Alan Mackenzie @ 2012-02-23 21:58 UTC (permalink / raw
To: gentoo-user
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
> <paul.hartman+gentoo@gmail.com> wrote:
> > On Thu, Feb 23, 2012 at 2:42 PM, Alan Mackenzie <acm@muc.de> 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).
^ permalink raw reply [flat|nested] 12+ messages in thread
* [gentoo-user] Re: dog - man's best friend.
2012-02-23 21:28 ` Kevin Monceaux
@ 2012-02-23 23:24 ` Harry Putnam
2012-02-23 23:40 ` Willie WY Wong
2012-02-24 0:02 ` Paul Hartman
0 siblings, 2 replies; 12+ messages in thread
From: Harry Putnam @ 2012-02-23 23:24 UTC (permalink / raw
To: gentoo-user
Kevin Monceaux <Kevin@RawFedDogs.net> writes:
> On Thu, Feb 23, 2012 at 08:42:00PM +0000, 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.
Maybe I'm seeing behavior that is not supposed to happen, but if I say
echo '## ONE LINE' > test
And then say less -F test
I do not get to see the one line. I don't think that's what Alan
was looking for is it?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] Re: dog - man's best friend.
2012-02-23 23:24 ` [gentoo-user] " Harry Putnam
@ 2012-02-23 23:40 ` Willie WY Wong
2012-02-25 21:19 ` Harry Putnam
2012-02-24 0:02 ` Paul Hartman
1 sibling, 1 reply; 12+ messages in thread
From: Willie WY Wong @ 2012-02-23 23:40 UTC (permalink / raw
To: gentoo-user
On Thu, Feb 23, 2012 at 06:24:29PM -0500, Penguin Lover Harry Putnam squawked:
> > On Thu, Feb 23, 2012 at 08:42:00PM +0000, 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.
>
> Maybe I'm seeing behavior that is not supposed to happen, but if I say
> echo '## ONE LINE' > test
>
> And then say less -F test
>
> I do not get to see the one line. I don't think that's what Alan
> was looking for is it?
That is not supposed to happen. Is that in a X terminal or on the text
console?
If you `less test` and quit, does the content of the test file stay on
screen or does it get cleared (I bet the former)? Try `less -XF test`
in that case, and see if it helps.
W
--
Data aequatione quotcunque fluentes quantitae involvente fluxiones invenire
et vice versa ~~~ I. Newton
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [gentoo-user] Re: dog - man's best friend.
2012-02-23 23:24 ` [gentoo-user] " Harry Putnam
2012-02-23 23:40 ` Willie WY Wong
@ 2012-02-24 0:02 ` Paul Hartman
2012-02-25 21:22 ` Harry Putnam
1 sibling, 1 reply; 12+ messages in thread
From: Paul Hartman @ 2012-02-24 0:02 UTC (permalink / raw
To: gentoo-user
On Thu, Feb 23, 2012 at 5:24 PM, Harry Putnam <reader@newsguy.com> wrote:
> Kevin Monceaux <Kevin@RawFedDogs.net> writes:
>
>> On Thu, Feb 23, 2012 at 08:42:00PM +0000, 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.
>
> Maybe I'm seeing behavior that is not supposed to happen, but if I say
> echo '## ONE LINE' > test
>
> And then say less -F test
>
> I do not get to see the one line. I don't think that's what Alan
> was looking for is it?
It is caused by "alternate screen" handling in your terminal emulator.
You can disable alternate screen in your terminal (if possible), or
remove the smcup and rmcup directives from your termcap file.
As a test, you can try this:
export TERM=vt220
less -F test
it should display the one line file.
Or you can use the -X option of less like Willie said which inhibits
less from using the alternate screen.
But I think it may still be a bug in less, because when it's not in
"pager mode" we shouldn't be using the alternate screen anyway. Taking
a look at the bug list on the less website, I don't see anything.
Might be worth submitting.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [gentoo-user] Re: dog - man's best friend.
2012-02-23 23:40 ` Willie WY Wong
@ 2012-02-25 21:19 ` Harry Putnam
0 siblings, 0 replies; 12+ messages in thread
From: Harry Putnam @ 2012-02-25 21:19 UTC (permalink / raw
To: gentoo-user
Willie WY Wong <wongwwy@member.ams.org> writes:
> On Thu, Feb 23, 2012 at 06:24:29PM -0500, Penguin Lover Harry Putnam squawked:
>> > On Thu, Feb 23, 2012 at 08:42:00PM +0000, 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.
>>
>> Maybe I'm seeing behavior that is not supposed to happen, but if I say
>> echo '## ONE LINE' > test
>>
>> And then say less -F test
>>
>> I do not get to see the one line. I don't think that's what Alan
>> was looking for is it?
>
> That is not supposed to happen. Is that in a X terminal or on the text
> console?
Real xterm in kde desktop (not konsole or any of the wannabes, just
plain xterm)
xterm -version
XTerm(276)
> If you `less test` and quit, does the content of the test file stay on
> screen or does it get cleared (I bet the former)? Try `less -XF test`
> in that case, and see if it helps.
(I guess you meant `latter'... not `former' eh?)
Here it is cleared... and yup `less -XF test' does as expected. less
doesn't start but the one line is shown.
(For the record: I have never used any of that and have no intention
or need to. I just saw the thread, tried it myself and saw what I
posted.)
Thanks for the input.
Oh, and this is all happening on a Debian (Testing) machine.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [gentoo-user] Re: dog - man's best friend.
2012-02-24 0:02 ` Paul Hartman
@ 2012-02-25 21:22 ` Harry Putnam
0 siblings, 0 replies; 12+ messages in thread
From: Harry Putnam @ 2012-02-25 21:22 UTC (permalink / raw
To: gentoo-user
Paul Hartman <paul.hartman+gentoo@gmail.com> writes:
[...]
>>> (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.
>>
>> Maybe I'm seeing behavior that is not supposed to happen, but if I say
>> echo '## ONE LINE' > test
>>
>> And then say less -F test
>>
>> I do not get to see the one line. I don't think that's what Alan
>> was looking for is it?
>
> It is caused by "alternate screen" handling in your terminal emulator.
> You can disable alternate screen in your terminal (if possible), or
> remove the smcup and rmcup directives from your termcap file.
>
> As a test, you can try this:
>
> export TERM=vt220
> less -F test
>
> it should display the one line file.
>
> Or you can use the -X option of less like Willie said which inhibits
> less from using the alternate screen.
OK, thanks for the input... good information. I'm not really likely
to use that command much or ever... but good to know.
I guess you see the same behavior I reported? That is, that a one
line file is not displayed with `less -F file' ?
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2012-02-25 21:26 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-23 20:42 [gentoo-user] dog - man's best friend Alan Mackenzie
2012-02-23 20:52 ` [gentoo-user] " Nikos Chantziaras
2012-02-23 20:58 ` [gentoo-user] " Neil Bothwick
2012-02-23 21:28 ` Kevin Monceaux
2012-02-23 23:24 ` [gentoo-user] " Harry Putnam
2012-02-23 23:40 ` Willie WY Wong
2012-02-25 21:19 ` Harry Putnam
2012-02-24 0:02 ` Paul Hartman
2012-02-25 21:22 ` Harry Putnam
2012-02-23 21:32 ` [gentoo-user] " Paul Hartman
2012-02-23 21:37 ` Paul Hartman
2012-02-23 21:58 ` Alan Mackenzie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox