-
-
Notifications
You must be signed in to change notification settings - Fork 673
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plugins: Add "colored-man-pages" plugin (#619)
- Loading branch information
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Colored Man Pages Plugin | ||
|
||
Adds colors to [`man`](https://man7.org/linux/man-pages/man1/man.1.html) pages. | ||
|
||
To use it, add `colored-man-pages` to the plugins array in your .bashrc file. | ||
|
||
```bash | ||
plugins=(... colored-man-pages) | ||
``` | ||
|
||
It will also automatically colorize man pages displayed by `dman` or `debman`, | ||
from [`debian-goodies`](https://packages.debian.org/stable/debian-goodies). | ||
|
||
You can also try to color other pages by prefixing the respective command with `colored`: | ||
|
||
```bash | ||
colored git help clone | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#! bash oh-my-bash.module | ||
# | ||
# Colored Man Pages Plugin | ||
# | ||
# This plugin is based on the following Oh-My-Zsh plugin: | ||
# https://github.com/ohmyzsh/ohmyzsh/blob/6bc4c80c7db072a0d2d265eb3589bbe52e0d2737/plugins/colored-man-pages/colored-man-pages.plugin.zsh | ||
|
||
# Adds the LESS_TERMCAP_* variables to color the man pages. | ||
function colored { | ||
local -x LESS_TERMCAP_mb=$_omb_term_red | ||
local -x LESS_TERMCAP_md=$_omb_term_bold_red | ||
local -x LESS_TERMCAP_me=$_omb_term_reset | ||
local -x LESS_TERMCAP_so=$_omb_term_bold_yellow | ||
local -x LESS_TERMCAP_se=$_omb_term_reset | ||
local -x LESS_TERMCAP_us=$_omb_term_green | ||
local -x LESS_TERMCAP_ue=$_omb_term_reset | ||
|
||
# Prefer `less` whenever available, since we specifically configured | ||
# environment for it. | ||
local -x PAGER=$(type -P less || _omb_util_print "$PAGER") | ||
local -x GROFF_NO_SGR=1 | ||
|
||
command "$@" | ||
} | ||
|
||
# Wrapper for man to colorize the output. | ||
_omb_util_binary_exists man && | ||
function man { | ||
colored "$FUNCNAME" "$@" | ||
} | ||
|
||
# Wrapper for dman to colorize the output. | ||
_omb_util_binary_exists dman && | ||
function dman { | ||
colored "$FUNCNAME" "$@" | ||
} | ||
|
||
# Wrapper for debman to colorize the output. | ||
_omb_util_binary_exists debman && | ||
function debman { | ||
colored "$FUNCNAME" "$@" | ||
} |