Set default working directory for ipython console (terminal)
ipython notebook has a default working directory setting
c.FileNotebookManager.notebook_dir = '/path/to/my/desired/dir'
Is there a similar setup for the ipython console (terminal)? I tried to tweak the following config option:
c.TerminalInteractiveShell.ipython_dir = '/path/to/my/desired/dir'
but that doesn't seem to have any effect. There are also no comments on how this parameter should act.
How do I configure ipython
so that my working directory is at startup /path/to/my/desired/dir
, no matter where I start ipython
?
source to share
From your home directory navigate to .ipython
, then your profile directory (possibly profile_default
), then startup
. There, create a new file with the extension .ipy
containing the lines:
import os
os.chdir('/path/to/my/desired/dir')
As crowie points out in the comments, the extension .ipy
also allows you to use IPython magic commands, so you can instead say:
%cd /path/to/my/desired/dir
source to share