I want to jump straight to the description of an option of a command. Something like man ls -la
or gcc -g
or cat -n
etc. you get it.
Is there a way to do that?
1 Answer
What I typically do is in a man page hit /
, and then type something to search.
Or if you want to jump directly to a section you could use man --pager
. For example, if you wanted to go to the section about -h
of ls
you could do man --pager='less -p -h' ls
. This could easily be made into a little bash script if you want to use this all the time.
If you want to jump directly to a section, and avoid hangups add 4 spaces in front of the section like so, man --pager='less -p " -h"' ls
.
-
the problem with this that it jumps to the first occurrence of the parameter not to the description. Eg. if there is a short description of the often used options in the head of the man page, then it shows that.– godzsaCommented May 4, 2016 at 19:18
-
Well, you'll have to make your search more specific. So, I see that if I do
man --pager='less -p -l' ls
it hits the--author
section which references-l
. To make it more specific adding a tab to the front of the search will go directly to the description, like thisman --pager='less -p " -l"' ls
. Seeing as all description subsections have tabs in front of them, this could be scripted for your desired effect. I'll add an example in my main post.– vescheCommented May 4, 2016 at 19:30 -
Sure but this is not exactly what I am looking for. Maybe there is no way to do that. I am trying to make your solution work with gcc -g but it won't work– godzsaCommented May 4, 2016 at 19:37
-
... I can't figure out how to do multiple spaces in markdown in the comments, but pretend there is 4 spaces before the
-l
in that last command in my previous comment.– vescheCommented May 4, 2016 at 19:37 -
The syntax provided will allow you to jump straight to the description of a command which is exactly what you said you were looking for. You can easily clean this up by adding it into a bash script like
man --pager='less -p $2' $1
call it something like manjump, and then call it withmanjump ls -l
and it will be pretty smooth.– vescheCommented May 4, 2016 at 19:41