Created
September 13, 2017 00:33
-
-
Save leogama/d754a8bc2d7a42ac45c70a6d38331d0a to your computer and use it in GitHub Desktop.
A smartish 'man' command for bash
This file contains hidden or 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
function man { | |
local CMD=${@: -1} | |
# Strangely, 'whatis' and even 'man -f' may fail to find the command. | |
if whatis $CMD &>/dev/null || [[ $(info -w $CMD) == '*manpages*' ]]; then | |
command man "$@" | |
elif info -w &>/dev/null; then | |
info "$@" | |
else | |
for HELP in --help -h -help --usage; do | |
if $CMD $HELP &>/dev/null; then | |
$CMD $HELP | less | |
return | |
fi | |
done | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment