R:设置命令行 Readline 初始化文件位置

R: set command line Readline init file location

根据 https://cran.r-project.org/doc/manuals/r-release/R-intro.html#The-command_002dline-editor,对于 R 命令行,Readline 初始化文件默认为 ~/.inputrc。有没有办法为此文件指定另一个位置?

来自Bash manual:

Any user can customize programs that use Readline by putting commands in an inputrc file, conventionally in his home directory. The name of this file is taken from the value of the shell variable INPUTRC. If that variable is unset, the default is ~/.inputrc. If that file does not exist or cannot be read, the ultimate default is /etc/inputrc.

When a program which uses the Readline library starts up, the init file is read, and the key bindings are set.

因此,只要您使用的是 Bash,您安装了 Readline,并且 R 被配置为查找和使用 Readline:

$ export INPUTRC=path/to/init && R

如果您只需要特定于 R 的定制,那么您可以在 ~/.inputrc 中使用 $if 指令以应用为条件。来自 R-intro manual 的示例:

$if R
  "\C-xd": "q('no')\n"
$endif

您可能已经知道了,因为您的问题包含相同的 link。我主要是为遇到此问题的其他人提及它。