gpt4 book ai didi

python - iPython 不读取 ~/.inputrc

转载 作者:太空狗 更新时间:2023-10-30 03:02:32 24 4
gpt4 key购买 nike

我正在使用 iPython。文档说我应该能够使用 inputrc 重新映射 readline 库的键。这是我的 inputrc 中的内容:

set editing-mode emacs
set keymap emacs
Meta-h: backward-word
Meta-s: forward-word
Control-h: backward-char
Control-s: forward-char
Control-n: previous-history
Control-t: next-history
Control-p: yank
Meta-p: yank-pop

当我加载 iPython 时,这些映射根本不起作用。我在 OS X 10.9 Mavericks 上。我没有看到任何关于使用 libedit 而不是 readline 的警告。有什么想法吗?

最佳答案

来自IPython Documentation :

All these features are based on the GNU readline library, which has an extremely customizable interface. Normally, readline is configured via a file which defines the behavior of the library; the details of the syntax for this can be found in the readline documentation available with your system or on the Internet. IPython doesn’t read this file (if it exists) directly, but it does support passing to readline valid options via a simple interface. In brief, you can customize readline by setting the following options in your configuration file (note that these options can not be specified at the command line):

readline_parse_and_bind: this holds a list of strings to be executed via a readline.parse_and_bind() command. The syntax for valid commands of this kind can be found by reading the documentation for the GNU readline library, as these commands are of the kind which readline accepts in its configuration file.

readline_remove_delims: a string of characters to be removed from the default word-delimiters list used by readline, so that completions may be performed on strings which contain them. Do not change the default value unless you know what you’re doing.

因此,您必须在配置文件中设置readline_parse_and_bind(默认情况下,这是在/path/to/ipython/dir/profile_default/ipython_config中。您可以使用 ipython profile create 示例生成默认配置。

关于python - iPython 不读取 ~/.inputrc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21793051/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com