Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to show current directory in ipython prompt

Tags:

Is there is way to show the current directory in IPython prompt?

Instead of this: In [1]:  Something like this: In<~/user/src/proj1>[1]: 
like image 233
motam79 Avatar asked Jul 20 '16 12:07

motam79


People also ask

How do I run IPython from command prompt?

The easiest way is to run easy_install ipython[all] as an administrator (start button, type cmd , shift+right click on “cmd.exe” and select “Run as administrator”). This installs the latest stable version of IPython including the main required and optional dependencies.


2 Answers

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

In [8]: import os  In [9]: os.getcwd() Out[9]: '/home/rockwool'  In [10]: pwd Out[10]: '/home/rockwool' 
like image 94
DurgaDatta Avatar answered Sep 21 '22 05:09

DurgaDatta


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.

like image 23
David Miller Avatar answered Sep 20 '22 05:09

David Miller