From 9b119866dd0e2d5054abd992f4dfbf346ac81b0d Mon Sep 17 00:00:00 2001 From: ratijas Date: Thu, 12 Nov 2020 21:32:17 +0300 Subject: [PATCH] refactor(colored-man-pages): move nroff wrapper and refactor logic in `colored` function (#9437) --- plugins/colored-man-pages/README.md | 14 ++++ .../colored-man-pages.plugin.zsh | 73 +++++++++++-------- plugins/colored-man-pages/nroff | 12 +++ 3 files changed, 67 insertions(+), 32 deletions(-) create mode 100755 plugins/colored-man-pages/nroff diff --git a/plugins/colored-man-pages/README.md b/plugins/colored-man-pages/README.md index f34941e73..4cbf64d3e 100644 --- a/plugins/colored-man-pages/README.md +++ b/plugins/colored-man-pages/README.md @@ -16,3 +16,17 @@ You can also try to color other pages by prefixing the respective command with ` ```zsh colored git help clone ``` + +## Customization + +The plugin declares global associative array `less_termcap`, which maps termcap capabilities to escape +sequences for the `less` pager. This mapping can be further customized by the user after the plugin is +loaded. Check out sources for more. + +For example: `less_termcap[md]` maps to `LESS_TERMCAP_md` which is the escape sequence that tells `less` +how to print something in bold. It's currently shown in bold red, but if you want to change it, you +can redefine `less_termcap[md]` in your zshrc file, after OMZ is sourced: + +```zsh +less_termcap[md]="${fg_bold[blue]}" # this tells less to print bold text in bold blue +``` diff --git a/plugins/colored-man-pages/colored-man-pages.plugin.zsh b/plugins/colored-man-pages/colored-man-pages.plugin.zsh index ec518472c..37faed672 100644 --- a/plugins/colored-man-pages/colored-man-pages.plugin.zsh +++ b/plugins/colored-man-pages/colored-man-pages.plugin.zsh @@ -1,39 +1,48 @@ -if [[ "$OSTYPE" = solaris* ]] -then - if [[ ! -x "$HOME/bin/nroff" ]] - then - mkdir -p "$HOME/bin" - cat > "$HOME/bin/nroff" <