2014-01-17 34 views
2

系統: OS X 10.9.x(小牛)`MANPATH`的不同配色方案?

目標:爲了能夠更改用於根據顯示的頁面是否在系統默認位置(/usr/share/man/…)聯機幫助的配色方案或軟件包管理器安裝的手冊頁的位置(/usr/local/share/man/…)。

我對manpages的渲染過程只有模糊的認識。我知道那個人把頁面交給某種預處理器(troff?),並且在頁面顯示在less之前發生了一些事情。但就是這樣。 :/

+0

我不知道爲什麼你想要改變配色方案,但我只能這樣讀取OS X上的手冊頁:'function pman {man -t「$ 1」|打開-f -a預覽; }'這會在'pman rsync'預覽中打開一個PDF版本。希望這可能有所幫助。 –

回答

0

根據以下question on Unix StackExchange,手冊頁的配色方案基於傳遞給尋呼機的環境變量設置。

對於不太這些都是中描述的少的termcap變量以下question on Unix StackExchange

一個簡單的解決問題的方法一個shell腳本,看起來像

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