A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/victor-gp/cmd-help-sublime-syntax/wiki/Configuration-tips below:

Configuration tips · victor-gp/cmd-help-sublime-syntax Wiki · GitHub

The following configuration tips work for Bash, Zsh and Fish unless otherwise stated.

These config lines should go in your respective shell's configuration file (.bashrc, .zshrc, .config.fish, etc.)

There's a snippets section at the end including all of the options discussed here.

Contributions are very welcome for covering other shell environments, including Windows shells like Powershell.

bathelp alias (basic configuration)

Add an alias with all the options you want when running a help message through bat + cmd-help.

For instance, the bare minimum is this:

alias bathelp="bat --plain --language=help"

Then you can use it like $ <CMD> --help | bathelp

You may want to add further options to the bat command:

You can add a help function so you can do $ help <CMD>

For Bash, Zsh:

help() {
    "$@" --help 2>&1 | bathelp
}

For Fish:

function help
    $argv --help 2>&1 | bathelp
end

Caveats, considerations:

--help enhancement (Zsh, Fish)

You can make --help into a global alias (Zsh) or an abbreviation (Fish) to enhance the default form: $ <CMD> --help

You can also do the same for the shorthand -h.

For Zsh:

alias -g -- --help='--help 2>&1 | bathelp'
alias -g -- -h='-h 2>&1 | bathelp'

For Fish:

abbr --add --position=anywhere -- --help '--help 2>&1 | bathelp'
abbr --add --position=anywhere -- -h '-h 2>&1 | bathelp'

Caveats, considerations:

Removing special characters from the help message

Some commands format their help messages with characters that are intractable to cmd-help. In such cases, the syntax exits early.

However, you can ensure the syntax functions as expected by removing those special characters before cmd-help parses the help message.

Removing overstrike formatting

Some commands use overstriking for their help messages (e.g.: less, fish).

You can remove overstriking by adding this sed filter before the bat command:

alias bathelp="sed 's/.\x08//g' | bat --plain --language=help"
Removing ANSI escape sequences

cmd-help can't handle escape sequences like color codes, bold or underline.

Most commands don't include this kind of formatting in their help message when they run into a pipe, like when using bathelp. But some still print them (e.g.: the delta git pager).

You can remove escape sequences by adding --strip-ansi to your bathelp options:

alias bathelp="bat --plain --language=help --strip-ansi=always"

Caveats, considerations:

These snippets include all of the options discussed in this page. Use the snippet that applies to your shell.

We recommend that you make this config yours by removing things you don't want/need, customizing the bat theme, perhaps adding other bat options, etc.

alias bathelp="sed 's/.\x08//g' | bat --plain --language=help --strip-ansi=always"
help() {
    "$@" --help 2>&1 | bathelp
}
alias bathelp="sed 's/.\x08//g' | bat --plain --language=help --strip-ansi=always"
help() {
    "$@" --help 2>&1 | bathelp
}
alias -g -- --help='--help 2>&1 | bathelp'
alias -g -- -h='-h 2>&1 | bathelp'
alias bathelp="sed 's/.\x08//g' | bat --plain --language=help --strip-ansi=always"
function help
    $argv --help 2>&1 | bathelp
end
abbr --add --position=anywhere -- --help '--help 2>&1 | bathelp'
abbr --add --position=anywhere -- -h '-h 2>&1 | bathelp'

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4