“MANPATH”的不同配色方案?

时间:2014-01-17 18:14:43

标签: macos terminal customization tty man

系统:OS X 10.9.x(Mavericks)

目标:根据显示的页面是否位于默认系统位置(/usr/share/man/…)或安装包管理器的位置,能够更改用于联机帮助页的颜色方案manpages live(/usr/local/share/man/…)。

我对联机填充程序的呈现过程只有模糊的认识。我知道那个人将页面移交给某种预处理器(troff?),并且在页面显示在less之前会发生一些事情。但那是关于它的。 :/

1 个答案:

答案 0 :(得分:0)

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

对于较少的这些是较少的termcap变量,在以下question on Unix StackExchange

中描述

一个简单的解决方案,一个看起来像

的shellcript
#!/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