I use "--help"
or "-h"
a lot. By default it uses cat
to open help file. How can i set it to use less
by default. I want the result of "command --help |less"
to be the same as "command --help"
Asked
Active
Viewed 212 times
0

seven-phases-max
- 11,765
- 1
- 45
- 57

tyler durden
- 35
- 5
-
You can use: man
– Pablo Sep 10 '18 at 10:00 -
No man is long and distracts – tyler durden Sep 10 '18 at 10:35
2 Answers
3
An alias for --help
wouldn't work. Aliases only apply to command names, not to their arguments. I wouldn't recommend a completely invisible solution, anyways. Too much command-line magic can create bad habits.
You could create a help command instead.
h() { "$@" --help | less; }
$ h cat
Usage: cat [OPTION]... [FILE]...
<snip>

John Kugelman
- 349,597
- 67
- 533
- 578
2
Commands to not default to cat
they just write to standard output.
Some comments (e.g., man
) send the output to the application specified by the PAGER
variable. You can set it to your favourite pager
export PAGER=less
But this will only work for applications that actually support it.
Otherwise you will have to pipe your commands as in your question.

Matteo
- 14,696
- 9
- 68
- 106
-
no PAGER doesn't work, creating alias may be? "--help" to be "--help |less" – tyler durden Sep 10 '18 at 10:24
-
-