我正在阅读《皮卡克斯的红宝石》一书(ruby版本2.0),但我无法执行这条语句。
$ export RI="--format ansi --width 70"
我使用的是Ubuntu 12.04的原生控制台,在RVM中使用了ruby。
书中解释该主题的部分
For general help on using ri, type ri --help. In particular, you might want to experiment with
the --format option, which tells ri how to render decorated text (such as section headings). If
your terminal program supports ANSI escape sequences, using --format=ansi will generate a
nice, colorful display. Once you find a set of options you like, you can set them into the RI
environment variable. Using our shell (zsh), this would be done using the following:
$ export RI="--format ansi --width 70"
我的控制台。这看起来很糟糕ESC=?
trabajo@fernando:~$ export RI="--format ansi --width 70" trabajo@fernando:~$ ri assoc
ESC[0mESC[1;32m.assocESC[m
(from ruby core) ESC[32mImplementation from ArrayESC[m
------------------------------------------------------------------------------ ary.assoc(obj) -> new_ary or nil
假设你的 TERM
环境变量设置正确(无论是 xterm-color
或 xterm-256color
应该够了)很可能是以下机构的呼叫器出了问题 ri
来自 ri
用户手册。
要使用ANSI,要么禁用寻呼机,要么告诉寻呼机允许使用控制字符。
所以你有两个选择,真的。
禁用呼叫器:
ri -T -f ansi assoc
使用支持ANSI的寻呼机,例如: less -R
:
PAGER="less -R" ri -f ansi assoc
你可以建立 -T
选项到您的 RI
环境变量,否则也要导出 PAGER
环境变量之外,还有 RI
之一。