Board logo

主題: [教學]親愛的...我把man page變彩色了 [打印本頁]

發表人: miholee    時間: 2007-7-18 12:02 AM     主題: [教學]親愛的...我把man page變彩色了

將下列文字加入 ~/.bashrc

# For colourful man pages (CLUG-Wiki style)
export LESS_TERMCAP_mb=$'\E[01;31m'
export LESS_TERMCAP_md=$'\E[01;31m'
export LESS_TERMCAP_me=$'\E[0m'
export LESS_TERMCAP_se=$'\E[0m'
export LESS_TERMCAP_so=$'\E[01;44;33m'
export LESS_TERMCAP_ue=$'\E[0m'
export LESS_TERMCAP_us=$'\E[01;32m'

重新登入或者執行 source ~/.bashrc 後,隨便 man 一個指令就可以看到 man page 變彩色了。

註: 以上改法僅適用於 bash;若是 csh 使用者, 將上述 export A=B 改寫成 setenv A B 應該就可以了。

[miholee 在  2007-7-18 12:03 AM 作了最後編輯]
發表人: Chicken    時間: 2007-7-18 05:52 AM

試過確實有效
在瀏覽方面變得更友善了
謝謝分享
發表人: ami    時間: 2007-7-18 09:01 AM

謝謝提供心得教學分享!
發表人: wintwelve    時間: 2007-8-11 09:42 PM

確實有效,一定要支持一下!
發表人: kills55555    時間: 2007-8-28 11:42 PM

嗯 既然有 這個有關man page的發文
想請教 我的man page 有時會有出現亂碼

這個要怎麼修呢?  也許是整個系統的語系不對
發表人: Chicken    時間: 2007-8-29 02:45 PM

請問你是在本機看還是用遠端連線看才亂碼的?
發表人: kills55555    時間: 2007-8-30 10:07 AM

嗯 這台是我們的server,沒辦法去本機看,不是我管的(但大家都有root的權限 所以要改系統是ok的)
我用SecureCRT連過去的(ssh)

我貼個man page 上來
--------------------------------------------------------------------------------------
FOPEN(3)                   Linux Programmer’s Manual                  FOPEN(3)

NAME
       fopen, fdopen, freopen - stream open functions

SYNOPSIS
       #include <stdio.h>

       FILE *fopen(const char *path, const char *mode);
       FILE *fdopen(int fildes, const char *mode);
       FILE *freopen(const char *path, const char *mode, FILE *stream);
.
.
.
       The mode string can also include the letter ‘‘b’’ either as a last character or as a charac-
       ter between the characters in any of the two-character strings  described  above.   This  is
       strictly  for  compatibility with ANSI X3.159-1989 (‘‘ANSI C’’) and has no effect; the ‘‘b’’

            is ignored on all POSIX conforming systems, including Linux.  (Other systems may treat  text
       files and binary files differently, and adding the ‘‘b’’ may be a good idea if you do I/O to
       a binary file and expect that your program may be ported to non-Unix environments.)
--------------------------------------------------------------------------------------
這是我的man fopen ..  出一堆亂碼
我看通通是問號(??) 貼到論壇上不是問號了,但還是亂碼
發表人: kills55555    時間: 2007-8-30 10:25 AM

嗯..  花了點時間 我找到解法了
主要就是語系的問題...

/etc/sysconfig/i18n 這檔應該是管大家的語系
也不用改這改動到大家的設定
我們整個server只有我看亂碼看的不高興
所我在.bashrc下加一行
LANG="en_US"
這樣亂碼就不見了...

本來在i18n 中是LANG="en_US.UTF-8"
就是它害的..  這樣改也許還不夠完善
但目前來說....   man page正常了
發表人: Chicken    時間: 2007-9-1 01:35 PM

如果你要編輯中文文檔
那可以考慮改成 zh_TW.UTF-8
而 SSH client 的 charset 也要改成 utf-8 喔
發表人: hohohahahaho    時間: 2007-9-20 10:27 PM

哈~這個有意思~
我來踹踹看
發表人: 柚祐    時間: 2007-11-3 11:24 PM

喔 ... 這個不錯喔,設了之後果然 man page 比較容易閱讀了,謝謝分享 ^^

PS: 能不能進一步解釋一下這些語法是什麼意思 ? 還能怎麼變化 ?




歡迎光臨 TWed2k (http://twed2k.org/) Powered by Discuz! 4.1.0