How to import "orange" in ipython notebook?

How can I make IPython import the aliases defined in my bash profile upon startup?

  • So far I've managed to place python files in ~/.ipython/profile_default/startup, and I have a clean list of aliases to define. Is there a way I can elegantly include my bash aliases as IPython aliases without copying and pasting?

  • Answer:

    Here is what I was able to do: # Configuration file for ipython. import re import os.path c = get_config() with open(os.path.expanduser('~/.bashrc')) as bashrc: for line in bashrc: if not line.startswith('alias'): continue parts = re.match(r'^alias (\w+)=([\'"]?)(.+)\2$', line.strip()) if not parts: continue source, _, target = parts.groups() c.AliasManager.user_aliases.append((source, target)) Drop https://gist.github.com/bfontaine/11352254 in ~/.ipython/profile_default/ipython_config.py. It parses your ~/.bashrc, extract aliases and import them for use in IPython. It handles both simple aliases (e.g. alias l=ls) and quoted ones (e.g. alias l="ls -lh"). You might get some warnings if some of your aliases override existing magic commands.

Baptiste Fontaine at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.