2

I would like to use batcat to colorize the output of the --help and -h options of commands, similar to the use of batcat colorization of the man pages.

I would like this to work on different shells, including Bash and Zsh.

There is a solution for the manpages where within the .*rc file (.bashrc or .zshrc) is added:

export MANPAGER="sh -c 'col -bx | batcat -l man -p'"
export MANROFFOPT="-c"

Is there an environment variable that can be used in a similar way for the --help/-h option?

Writing a function for it or piping it after every --help/-h query, like | bat -l help, doesn't look to be the most "beautiful" way to do this.

1
  • 5
    Commands all implement --help in their own ways, there's no standard (except maybe for GNU commands, but even then only for formatting and conventions). Many don't even have --help, but only -h, for instance, and a few pipe the output to a pager automatically (e.g., aws CLI), most dump the text to stderr but some output to stdout, etc., etc.
    – muru
    Commented Aug 12 at 7:41

1 Answer 1

4

Not what you're asking for.

But at least for commands supported by batcat -l help you could make use of some "syntactic sugar" instead of typing the whole thing in every time:

ch() { "${1}" --help | batcat -l help; }

In ~/.bashrc / ~/.zshrc.

Use only with Bash builtins or GNU programs (as those seem to be supported by batcat -l help: printf, find... - contrarily to what I stated in the comments, it won't work for Zsh builtins).

Usage:

ch <command>
ch find

screenshot

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .