2

The issue I have could be illustrated best with example:

I know curl lets me do POST requests but I don't remember how. So I open man curl, and begin to search for POST. The problem is that every result starts in the middle of some option's description, and I need to scroll (many) lines up to see the command and start of the description.

To be honest, I'm pretty sure searching for the same thing via web would be faster.

To make the process of walking through manpages more comfortable, I have two solutions in mind:

  1. Simulate vim's scrolloff feature that lets you to keep at least N lines above and below currently selected line.
  2. Use some other search, that instead of aligning the current line at the highlighted word, will align at the section start.

That way I'll be able to immediately see if the option I look for is relevant or not.

2

man uses less internally, and less has -j option that is almost like scrolloff feature (see this answer). Negative values keep the searches at the bottom of the screen.

So if you do info curl|less -j 4, you'll be able to search while keeping 4 lines above the text, and if you do info curl|less -j -4, you'll be able to search while keeping 4 lines below the text and "hugging" to the bottom screen edge (I believe this to be more useful.)

Instead of piping info to less manually, you can make your man do it as well by defining a environment variables for less (see this answer) - namely, LESS=-j4 will make less use -j4 by default. If you don't want to pollute the environment, you can make a function for man like this:

man() {
    env LESS=-j-4 man "$@"
}

This will cause it to run in a subshell so the variable will be cleared out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.