【问题标题】:Different color schemes by `MANPATH`?`MANPATH` 的不同配色方案?
【发布时间】:2014-01-17 18:14:42
【问题描述】:

系统: OS X 10.9.x(小牛)

目标: 能够根据显示的页面是在默认系统位置 (/usr/share/man/…) 还是 package-manager 安装手册页的位置来更改用于手册页的配色方案(/usr/local/share/man/…)。

我对联机帮助页的渲染过程只有一个模糊的认识。我知道那个人将页面交给某种预处理器(troff?),并且在页面显示在less 之前发生了一些事情。但仅此而已。 :/

【问题讨论】:

  • 我不知道您为什么要更改配色方案,但我只能通过这种方式阅读 OS X 上的手册页:function pman { man -t "$1" | open -f -a Preview; } 这会打开带有pman rsync 的预览 PDF 版本。希望这可能会有所帮助。

标签: macos terminal customization tty manpage


【解决方案1】:

根据以下question on Unix StackExchange,手册页的配色方案基于传递给寻呼机的环境变量设置。

这些是less termcap 变量,在以下question on Unix StackExchange 中进行了描述

一个简单的解决你的问题的shellscript,看起来像

#!/bin/bash
mancommand=`man -d $1 2>&1 | tail -1`
parts=( $mancommand );
path=${parts[8]};
if [[ $path == */usr/share/man/* ]]

then
       # One colour scheme
       LESS_TERMCAP_mb=$'\E[01;31m' \
       LESS_TERMCAP_md=$'\E[01;38;5;74m' \
       LESS_TERMCAP_me=$'\E[0m' \
       LESS_TERMCAP_se=$'\E[0m' \
       LESS_TERMCAP_so=$'\E[38;5;246m' \
       LESS_TERMCAP_ue=$'\E[0m' \
       LESS_TERMCAP_us=$'\E[04;38;5;146m' eval $mancommand
else
        # Second colour scheme
        LESS_TERMCAP_mb=$(tput bold; tput setaf 2) \
        LESS_TERMCAP_md=$(tput bold; tput setaf 6) \
        LESS_TERMCAP_me=$(tput sgr0) \
        LESS_TERMCAP_so=$(tput bold; tput setaf 3; tput setab 4) \
        LESS_TERMCAP_se=$(tput rmso; tput sgr0) \
        LESS_TERMCAP_us=$(tput smul; tput bold; tput setaf 7) \
        LESS_TERMCAP_ue=$(tput rmul; tput sgr0) \
        LESS_TERMCAP_mr=$(tput rev) \
        LESS_TERMCAP_mh=$(tput dim) \
        LESS_TERMCAP_ZN=$(tput ssubm) \
        LESS_TERMCAP_ZV=$(tput rsubm) \
        LESS_TERMCAP_ZO=$(tput ssupm) \
        LESS_TERMCAP_ZW=$(tput rsupm) eval $mancommand
fi

【讨论】:

    猜你喜欢
    • 2020-04-19
    • 1970-01-01
    • 2016-07-12
    • 1970-01-01
    • 1970-01-01
    • 2016-06-23
    • 1970-01-01
    • 1970-01-01
    • 2017-02-25
    相关资源
    最近更新 更多