Skip to content

Instantly share code, notes, and snippets.

@quickshiftin
Created February 21, 2014 07:25
Show Gist options
  • Star 40 You must be signed in to star a gist
  • Fork 13 You must be signed in to fork a gist
  • Save quickshiftin/9130153 to your computer and use it in GitHub Desktop.
Save quickshiftin/9130153 to your computer and use it in GitHub Desktop.
Running GNU coreutils via Homebrew on your Mac? Here's a one-liner to get the manpages working!
# Short of learning how to actually configure OSX, here's a hacky way to use
# GNU manpages for programs that are GNU ones, and fallback to OSX manpages otherwise
alias man='_() { echo $1; man -M $(brew --prefix)/opt/coreutils/libexec/gnuman $1 1>/dev/null 2>&1; if [ "$?" -eq 0 ]; then man -M $(brew --prefix)/opt/coreutils/libexec/gnuman $1; else man $1; fi }; _'
@tasmo
Copy link

tasmo commented Feb 24, 2016

@JacobDorman Do you use oh-my-zsh or prezto? There is an alias for sudo(!) which causes this failure. So try to comment out the line alias _='sudo' or add a line with unalias _ before the man alias.

@tasmo
Copy link

tasmo commented Feb 24, 2016

The alias is not working with bash.

@JacobDorman
Copy link

@tasmo Ahh so there is. I never use that. unalias _ fixes the issue.

@OJFord
Copy link

OJFord commented Oct 8, 2016

What's wrong with just putting /usr/local/opt/coreutils/libexec/gnuman at the front of $MANPATH?

@SystemDisc
Copy link

SystemDisc commented Jan 28, 2017

I have the same question as @OJFord. Why not just export MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"?

@si9ma
Copy link

si9ma commented Feb 3, 2019

man section will not work, use $@ instead of $1

alias man='_() { echo $@; man -M $(brew --prefix)/opt/coreutils/libexec/gnuman $@ 1>/dev/null 2>&1;  if [ "$?" -eq 0 ]; then man -M $(brew --prefix)/opt/coreutils/libexec/gnuman $@; else man $@; fi }; _'

@ciscohack
Copy link

This man hack command now not working in macOS 12.3.1 .. when i put this in my alias file and try to type man it stuck on "ma" only.. shall we have new workaround

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