Skip to content

Instantly share code, notes, and snippets.

@april
Last active March 12, 2022 20:59
Show Gist options
  • Save april/708215a49c9ad970262dc605a0595d5d to your computer and use it in GitHub Desktop.
Save april/708215a49c9ad970262dc605a0595d5d to your computer and use it in GitHub Desktop.
mansplain() {
user=`echo $USER | tr "[:lower:]" "[:upper:]"`
# ugh, macos vs linux
if command -v gzcat
then
_cat() { gzcat $@; }
else
_cat() { zcat $@; }
fi
# set pager if not set
if [ -z ${PAGER+x} ]; then PAGER=less; fi
_cat --force `man -w $1` | sed -E -e "s/\.SH \"?NAME\"?/.SH \"WELL ACTUALLY, $user, LET ME EXPLAIN...\"/" | groff -man -Tutf8 | $PAGER
}
@raphink
Copy link

raphink commented Mar 9, 2022

I don't know about other distros, but on Ubuntu manpages are zipped, so you need zcat instead of cat.

@april
Copy link
Author

april commented Mar 9, 2022

Fixed, added a lot of armor to make it cross platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment