Is there is way to show the current directory in IPython prompt?
有没有办法在IPython提示符下显示当前目录?
Instead of this:
In [1]:
Something like this:
In<~/user/src/proj1>[1]:
2 个解决方案
#1
2
https://ipython.org/ipython-doc/3/config/details.html#specific-config-details
https://ipython.org/ipython-doc/3/config/details.html#specific-config-details
In the terminal, the format of the input and output prompts can be customised. This does not currently affect other frontends.
在终端中,可以自定义输入和输出提示的格式。这目前不会影响其他前端。
So, in .ipython/profile_default/ipython_config.py, put something like: c.PromptManager.in_template = "In<{cwd} >>>"
因此,在.ipython / profile_default / ipython_config.py中,输入如下内容:c.PromptManager.in_template =“In <{cwd} >>>”
#2
6
You can use os.getcwd
(current working directory) or in the native os command pwd
.
您可以使用os.getcwd(当前工作目录)或在本机os命令pwd中使用。
In [8]: import os
In [9]: os.getcwd()
Out[9]: '/home/rockwool'
In [10]: pwd
Out[10]: '/home/rockwool'
#1
2
https://ipython.org/ipython-doc/3/config/details.html#specific-config-details
https://ipython.org/ipython-doc/3/config/details.html#specific-config-details
In the terminal, the format of the input and output prompts can be customised. This does not currently affect other frontends.
在终端中,可以自定义输入和输出提示的格式。这目前不会影响其他前端。
So, in .ipython/profile_default/ipython_config.py, put something like: c.PromptManager.in_template = "In<{cwd} >>>"
因此,在.ipython / profile_default / ipython_config.py中,输入如下内容:c.PromptManager.in_template =“In <{cwd} >>>”
#2
6
You can use os.getcwd
(current working directory) or in the native os command pwd
.
您可以使用os.getcwd(当前工作目录)或在本机os命令pwd中使用。
In [8]: import os
In [9]: os.getcwd()
Out[9]: '/home/rockwool'
In [10]: pwd
Out[10]: '/home/rockwool'