Skip to content

Instantly share code, notes, and snippets.

@marek-saji
Last active October 23, 2016 19:03
Show Gist options
  • Save marek-saji/e87c7d78cb62e19c02ae4b12ff85a025 to your computer and use it in GitHub Desktop.
Save marek-saji/e87c7d78cb62e19c02ae4b12ff85a025 to your computer and use it in GitHub Desktop.
man(1) wrapper that tries running a command with --help if no man page found
# If no man page found, try running the command with --help
man ()
{
if man -w "$1" >/dev/null 2>&1
then
command man "$@"
elif which "$1" >/dev/null
then
echo "No man page found for $1, trying --help..."
"$1" --help 2>&1 | less -S
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment