文件中标题的多彩格式RI

问题描述 投票:3回答:2

我正在阅读《皮卡克斯的红宝石》一书(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
ruby-on-rails ruby linux rvm
2个回答
1
投票

假设你的 TERM 环境变量设置正确(无论是 xterm-colorxterm-256color 应该够了)很可能是以下机构的呼叫器出了问题 ri

来自 ri 用户手册。

要使用ANSI,要么禁用寻呼机,要么告诉寻呼机允许使用控制字符。

所以你有两个选择,真的。

  • 禁用呼叫器:

    ri -T -f ansi assoc

  • 使用支持ANSI的寻呼机,例如: less -R:

    PAGER="less -R" ri -f ansi assoc

你可以建立 -T 选项到您的 RI 环境变量,否则也要导出 PAGER 环境变量之外,还有 RI 之一。


0
投票

你只需要用 unix命令 unset.

我遇到了同样的问题,只是运行这个。

unset RI

然后,如果你运行这样的东西 ri GC 它又会有默认的格式。

© www.soinside.com 2019 - 2024. All rights reserved.