Martin Vegter
Martin Vegter

Reputation: 527

set default working directory for ipython console (terminal)

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 ?

Upvotes: 3

Views: 3086

Answers (1)

jez
jez

Reputation: 15359

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

Upvotes: 6

Related Questions