Last active
April 25, 2017 11:49
-
-
Save pgmccann/86cf2aa493513815f277542343a517aa to your computer and use it in GitHub Desktop.
Having "man <cmd>" fall back on "<cmd> --help" in zsh with oh-myzsh colored-man-pages
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
function man() { | |
CLRD_MAN=$ZSH/plugins/colored-man-pages/colored-man-pages.plugin.zsh | |
PGR='less' | |
OTHER_OPTS=0 | |
while getopts ":P:" opt; do | |
case $opt in | |
P ) PGR=$OPTARG ;; | |
? ) OTHER_OPTS=1 ;; | |
esac | |
done | |
if (( OTHER_OPTS == 1 )) then | |
. $CLRD_MAN && man $@ | |
else | |
/usr/bin/man -P cat ${@: -1} > /dev/null && (. $CLRD_MAN && man $@) || (${@: -1} --help > /dev/null && ${@: -1} --help | $PGR || echo "No help content found") | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment