Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set default working directory for ipython console (terminal)

Tags:

ipython

ipython notebook has setting for default working directory

c.FileNotebookManager.notebook_dir = '/path/to/my/desired/dir'

is there analogous setting for ipython console (terminal) ? I have tried adjusting following configuration parameter:

c.TerminalInteractiveShell.ipython_dir = '/path/to/my/desired/dir' 

but this seems to have no effect. There is also no comment as to what this parameter is supposed to effect.

How can I configure ipython so that my working directory upon start will be /path/to/my/desired/dir, irrespective from where I started ipython ?

like image 799
Martin Vegter Avatar asked Jul 18 '26 11:07

Martin Vegter


1 Answers

From your home directory, go to .ipython, then your profile directory (probably profile_default), then startup. In there, create a new file with the extension .ipy, containing the lines:

import os
os.chdir('/path/to/my/desired/dir')

As pointed out by crowie in the comments, the .ipy extension also enables you to use IPython "magic" commands, so you could instead say:

%cd /path/to/my/desired/dir
like image 69
jez Avatar answered Jul 21 '26 09:07

jez