how to show current directory in ipython prompt how to show current directory in ipython prompt python python

how to show current directory in ipython prompt


You can use os.getcwd(current working directory) or in the native os command pwd.

In [8]: import osIn [9]: os.getcwd()Out[9]: '/home/rockwool'In [10]: pwdOut[10]: '/home/rockwool'


Using ! before pwd will show the current directory

In[1]: !pwd/User/home/

When interactive computing it is common to need to access the underlying shell. This is doable through the use of the exclamation mark ! (or bang) To execute a command when present in beginning of line.


According to:

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} >>>"