Skip to content

Instantly share code, notes, and snippets.

@supermarin supermarin/.env
Last active Oct 7, 2019

Embed
What would you like to do?
Colored `man` pages on OSX
# ZSH / BASH users
# Add this to your .env, .bashrc, .zshrc, or whatever file you're using for environment
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
# Fish users
# Save this file as ~/.config/fish/functions/man.fish
function man
env \
LESS_TERMCAP_mb=(printf "\e[1;31m") \
LESS_TERMCAP_md=(printf "\e[1;31m") \
LESS_TERMCAP_me=(printf "\e[0m") \
LESS_TERMCAP_se=(printf "\e[0m") \
LESS_TERMCAP_so=(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=(printf "\e[0m") \
LESS_TERMCAP_us=(printf "\e[1;32m") \
man "$argv"
end
@cafedomingo

This comment has been minimized.

Copy link

commented Sep 24, 2014

👍

@gf3

This comment has been minimized.

Copy link

commented Aug 29, 2016

you'll need to remove the quotes around "$@" and "$argv", otherwise it passes multiple arguments as a single argument; which makes it impossible to view different sections of the manual. e.g.: man 3 calloc

@suewonjp

This comment has been minimized.

Copy link

commented Dec 31, 2017

👍

BTW, @gf3 is telling incorrect info.

"$@" is supposed to pass multiple arguments. "$*" will pass multiple arguments as a single argument, though.
(Therefore, .env file is correct, at least)

See https://yakking.branchable.com/posts/whitespace-safety/

@sankalp-khare

This comment has been minimized.

Copy link

commented Feb 25, 2019

@supermarin, thanks for that man.fish! 🙇
Also what @gf3 says is correct, at least for fish --- removing the quotes from around "$argv" fixes the issue with invocations such as man 3 calloc. Thanks @gf3 for pointing it out 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.