Created
June 22, 2024 02:56
-
-
Save minhtrancccp/f1ec56d17c5be28aaee8cc97079152a5 to your computer and use it in GitHub Desktop.
an extension to the help builtin of bash, with stdout colorisation and paging of bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# based on https://github.com/sharkdp/bat#highlighting---help-messages | |
help() { | |
{ | |
set -x | |
command help "$@" 2>/dev/null | |
type -P "$1" && if echo "$@" | grep -Eq '(\s-h|help)(\s|$)'; then "$@"; else "$@" --help; fi | |
} |& bat -plhelp | |
} | |
complete -F _command help # https://stackoverflow.com/a/35356591/8867832 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment