Reputation: 2698
In ipython 0.10 and 0.11, is there an easy way to make and save aliases? I know there is discussion of allowing store of aliases for 0.12, but what can I do with my students that will be easy. I'd like to save this alias:
alias rtupdate (cd ~/projects/researchtools; hg pull; hg update)
Is the only real option to edit ~/.ipython/ipythonrc or follow http://ipython.scipy.org/Wiki/tips for 0.10 or work with the alias manager in 0.11 (http://wiki.ipython.org/Cookbook/Moving_config_to_IPython_0.11) ?
Students each have their own VMWare Ubuntu 11.04 virtual machine with ipython 0.10.1. I can make this a separate shell executable block in org-mode and add makefiles that will remind people how to do a pull and update with mercurial, but I have yet to explain what a Makefile is. e.g. this kind of hint:
https://bitbucket.org/schwehr/researchtools/src/829773b7db64/Makefile
Upvotes: 2
Views: 2097
Reputation: 38608
Are your students on their own machines, or do you control their environment?
If you want configuration to survive from one session to the next, the official way to do that is to edit your config, but there are other ways. For instance, you could write an IPython extension which defines extra aliases, and provide that to your students.
What may be easiest for your students, though, is to simply provide a script to run on startup, containing the lines you want to run, defining aliases, etc. You can call it something like init.ipy
, then just instruct IPython to run the script. This can be done in config with InteractiveShellApp.exec_files
, or you can just specify it at the command-line with ipython -i init.ipy
, or at any later point with %run init.ipy
.
Note that a script with the .ipy
extension is allowed to have IPython commands (e.g. %alias rtupdate (cd ~/projects/researchtools; hg pull; hg update)
), but if you use .py
it is treated as a regular Python script.
Upvotes: 4