|
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Hi,
Did someone ask for the percent indicator when using less with man pages?
I spent over an hour getting this just right!
I don't know exactly how this would be in (t)csh; quotes are funny animals. But here's
how it will look in bash. Put this in .bashrc:
export LESS=--prompt="%f (%pb\%)"
export PAGER=less
Then the indicator at the bottom will look like this:
/path/to/somewhere/filename (25%)
Now, how to make this work for man pages. Unfortunately, it requires creating a
temp file. This is because man pipes its output to your $PAGER, so less has no way
of knowing the percentage beforehand. I'd be interested if someone has a solution
to that.
That said, here's one way to do it; write a script:
#!/bin/bash
# Collect arguments and options
args="$@"
# Assume the last argument is the man page you're looking for and store it.
# (In other words, something like 'man_script ls mv rm' will only work as 'man rm'.)
currman=${args##* }
# Use cat to create a plain text version of the man page.
/usr/bin/man -P cat $@ > /tmp/less.$$
unset LESS
less --prompt="\ %%$currman\ (%pb\\%)" /tmp/less.$$
rm -f /tmp/less.$$
# End man_script
I called it simply 'm'. So, 'm rm' and the indicator will show
rm (27%)
And a Happy New Year to you all!
Ken
| References: | |
| >Re: odd output of "ls --color FILES | less" (From: Ken Engel <email@hidden>) |
| Home | Archives | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2011 Apple Inc. All rights reserved.