This is a simple question. Trying my best to put it in simple word. Hope you get it without much confusion –
I read a man page for some command-switch/option which has a long description. I read it, press q
to escape and try the option. But then I do need to go back to same man page section for some more info. So, I repeat the steps
I would like to know if there is any way to output the contents of man page onto the stdout for referring it quickly.
For example let's take short-one cal
, may be something like
cat `man cal`
would be effective and help achieve the desired requirement.
Any hints?
Best Answer
You could run the output of
man
into thecol
command and then pipe this toless
. Once inless
you can drop to a shell while still maintaining your location inless
.Once in
less
you can use!bash
to get to a prompt to do what you want. When you're done you typeexit
to return back to your location inless
.Example
Here's a demo showing the whole operation.
Tell man to use a different pager
You can also tell
man
to use different pagers via the-P
switch. So we could streamline the above method like so:This is invoking
man
and then outputting the contents of the page toless
, where again we can use!bash
to get to a shell. To return we use the same steps as above,exit
.What's wrong with the default pager?
Actually nothing.
It too can take the command
!bash
to escape to a shell, where again we can typeexit
to get back to the location where we were previously within the man page.What else?
If you're feeling really crazy you can use
vim
as an alternative pager too. Setting this up is a bit of a task but it's doable, directions for doing so are here in the vim wikia topic titled: Using vim as a man-page viewer under Unix.Don't let the above page fool you, it doesn't just cover
vim
methods. That topic covers dozens of ways you can change your man page pager in addition to usingvim
.