manページが白黒で寂しいなと感じたので、色をつけることにしました。
参考にしたページ
https://www.tecmint.com/view-colored-man-pages-in-linux/
2つの方法
参考にしたページでは、manページに色をつける方法として次の2つを紹介していました。
・ページャーをlessではなくmostにする ・LESS_TERMCAP変数を設定する
ページャーをmostにする方法
最初はmostを試してみました。
まず、mostをインストールします。
sudo apt install most
次に、.bashrcに以下の記述をして、ページャーをlessではなくmostにします。
export PAGER="most"
.bashrcの変更を反映させます。
source .profile
(.profileから.bashrcを読み込んでいるので、sourceの対象は.profileとなっています。)
これでmanページに色はついたものの、操作感がlessと違うのですぐにやめました^^;。
LESS_TERMCAP変数による方法
mostの使用はやめて、LESS_TERMCAP変数を設定することにしました。
(以下の内容は「参考にしたページ」からそのままコピペです。)
export LESS_TERMCAP_mb=$'\e[1;32m' export LESS_TERMCAP_md=$'\e[1;32m' export LESS_TERMCAP_me=$'\e[0m' export LESS_TERMCAP_se=$'\e[0m' export LESS_TERMCAP_so=$'\e[01;33m' export LESS_TERMCAP_ue=$'\e[0m' export LESS_TERMCAP_us=$'\e[1;4;31m' # Following are the color codes that we used in the above configuration. # 31 \u2013 red # 32 \u2013 green # 33 \u2013 yellow # And here are the meanings of the escape codes used in the above configuration. # 0 \u2013 reset/normal # 1 \u2013 bold # 4 \u2013 underlined
を.bashrcに追記して
source .profile
を実行しました。
実行結果