Issue
I use IPython 5.1.0 with Python 3.5.2 at the command line on OSX 10.11.6.
I would like to define bookmarks and command aliases to be loaded when I start the IPython interactive shell.
I thought I would be able to run magic commands in the ipython_config.py
configuration file (such as %bookmark FOLDERS /Users/tbaker/folders
), but this does not work -- with or without the leading percent sign %
.
Ideally, I would get these bookmarks from an external file of bookmark lines that is supposed to be shared between ipython
and bash
(for which I wrote a bookmark
function with the same functionality as IPython's bookmark
).
Nothing I have tried has worked, including an attempt to enclose the magic commands in various wrappers, e.g., get_ipython().magic(...
. Indeed, aliases and bookmarks appear to be designed for definition on the fly, at the IPython prompt, and not batch-loaded at startup time. Does anyone see a way either to define bookmarks in the IPython startup configuration files, or to have IPython fetch the bookmark definitions from another file on startup?
Solution
To run configuration commands at iPython startup locate the following line in your .ipython/profile_default/ipython_config.py
c.InteractiveShellApp.exec_lines = ['%alias echo show']
You can also have a file loaded with a bunch of iPython commands using c.InteractiveShellApp.exec_files = []
Hope this helps
Answered By - Jehandad
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.