Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Fix an annoying apropos glitch' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Fix an annoying apropos glitch
Authored by: MaxMarino on Jan 21, '05 12:39:17PM

This is no fix, sorry. It does not scale (fixed length). What if you change the terminal size?

The real fix, of course, is to modify the very same line but NOT with 'cut -c1-80' or whatever column number you might have tried it with in order to have instead a DYNAMIC: want to read more? enlarge the window and you read more text. Text is not lost and it goes as far as the terminal size.

How? Just add, in the same line as the original hint(???) '-S' after $PAGER and you have the real fix. Have this since ages...



[ Reply to This | # ]
Where to put the less -S flag
Authored by: gshenaut on Jan 21, '05 01:33:00PM

Adding an -S flag after $PAGER is not a good way to do this, because it assumes that PAGER is set to less(1). Consider what would happen if PAGER were set in the environment to some other command, such as "xmessage -file -": if there is an -S flag after $PAGER, the program will simply fail to work.

If you look at the script, you will see that PAGER is defined to less plus some flags (PAGER="less -Rse"; the flags mean interpret control chars, squeeze multiple empty lines to one, and exit at EOF). It would make perfect sense to add the S flag to that definition ("PAGER=less -SRse") instead of the cut filter I suggested.

But, the -S flag is a good steer, thanks.

Greg Shenaut



[ Reply to This | # ]
Where to put the less -S flag
Authored by: arekkusu on Jan 21, '05 02:11:40PM

But, it is only set to less if it is undefined. What if you normally have it set to something else, like 'less -ERmX~'?



[ Reply to This | # ]
Where to put the less -S flag
Authored by: gshenaut on Jan 21, '05 04:12:09PM
Yeah, it's kind of an endless loop, isn't it? Well, you could put an "apropos" shim like this into your personal bin directory:
#!/bin/sh
PAGER="less -xxxS"; export PAGER
exec /usr/bin/apropos $*
so that the PAGER definition is overridden. I still think the original file should be changed by adding the -S to its default PAGER definition. (The "xxx" gets replaced with whatever your other less preferences are.)

Greg Shenaut

[ Reply to This | # ]

Fix an annoying apropos glitch
Authored by: zs on Jan 21, '05 11:09:51PM
How about using something like:
cut -c1-`command that gets terminal width`
After some mucking around (using the "apropos" command, appropriately enough) I haven't found a command that can give me this information. Anyone know a way to do this?

---
zs

[ Reply to This | # ]

Fix an annoying apropos glitch
Authored by: zs on Jan 21, '05 11:12:56PM

Of course this isn't dynamic, but it should work at whatever the terminal width is before 'apropos' is executed. It seems that there is no perfect solution to this problem.

---
zs



[ Reply to This | # ]
shell width command
Authored by: gshenaut on Jan 22, '05 09:15:42AM
I think the -S flag is probably a better way to handle apropos, but you could alternatively use this (possibly somewhat fragile) cut command:
cut -c1-`stty all | head -1 | cut -d' ' -f6`

Greg Shenaut

[ Reply to This | # ]

shell width command
Authored by: perturb on Jan 25, '05 09:20:09AM
Less fragile stty:
stty size |cut -d' ' -f2


[ Reply to This | # ]