[英]iPython - change color for double underscore (magic) attributes?
I updated iPython to:我将 iPython 更新为:
Python 3.6.7 (default, Mar 29 2019, 10:38:28)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.
What I noticed is that double underscore attribute likes __name__
have dark blue color.我注意到的是像
__name__
这样的双下划线属性具有深蓝色。 My terminal is black, so those attributes are ridiculously dark and hard to see (look at A.__name__
):我的终端是黑色的,所以这些属性暗得离谱且难以看到(看看
A.__name__
):
Is there a way to modify colors on iPython?..有没有办法在 iPython 上修改颜色?..
I found this question, but it seems with 7.4.0
iPython, given answers no longer work.我发现了这个问题,但似乎在
7.4.0
iPython 中,给出的答案不再有效。
How do I customize text color in IPython? 如何在 IPython 中自定义文本颜色?
Looking in your installation directory you will find a file called ipython_config.py
.查看您的安装目录,您会发现一个名为
ipython_config.py
的文件。 To install this file, simply use the following command:要安装此文件,只需使用以下命令:
ipython profile create
Otherwise find this file and copy it in your ~/.ipython/profile_default/
directory.否则找到此文件并将其复制到您的
~/.ipython/profile_default/
目录中。
Before editing it, make a backup of this file with:在编辑它之前,请使用以下命令备份此文件:
cp ~/.ipython/profile_default/ipython_config.py \
~/.ipython/profile_default/ipython_config.py_backup
Open this file with your editor of choice, search for following setting and comment it out (delete the '#'):使用您选择的编辑器打开此文件,搜索以下设置并将其注释掉(删除“#”):
#c.TerminalInteractiveShell.highlighting_style_overrides = {}
you must have next code there:你必须在那里有下一个代码:
## Override highlighting format for specific tokens
from pygments.token import Name
c.TerminalInteractiveShell.highlighting_style_overrides = {
Name.Variable: "#FF00FF"
}
You can override the highlight color for any of the tokens defined in pygments
- there's a list in the pymgents documentation . 您可以覆盖
pygments
定义的任何标记的突出显示颜色 - pymgents文档中有一个列表。 The token you want to change is Name.Function.Magic
. 您要更改的令牌是
Name.Function.Magic
。 To do that, add the following to your ipython_config.py
file (mine is in ~/.ipython/profile_default
): 为此,请将以下内容添加到
ipython_config.py
文件中(我的文件位于~/.ipython/profile_default
):
from pygments.token import Token
c.TerminalInteractiveShell.highlighting_style_overrides = {
Token.Name.Function.Magic: '#FF00FF'
}
This will make magic functions highlight in magenta - your preferences may vary :) 这将使洋红色的魔术功能突出显示 - 您的喜好可能会有所不同:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.