Skip to content

Instantly share code, notes, and snippets.

@leogama
Created September 13, 2017 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leogama/d754a8bc2d7a42ac45c70a6d38331d0a to your computer and use it in GitHub Desktop.
Save leogama/d754a8bc2d7a42ac45c70a6d38331d0a to your computer and use it in GitHub Desktop.
A smartish 'man' command for bash
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