Skip to content

Instantly share code, notes, and snippets.

@bfontaine
Created April 27, 2014 18:26
Show Gist options
  • Save bfontaine/11352254 to your computer and use it in GitHub Desktop.
Save bfontaine/11352254 to your computer and use it in GitHub Desktop.
Import your ~/.bashrc aliases in IPython
# Configuration file for ipython.
import re
import os.path
c = get_config()
with open(os.path.expanduser('~/.bashrc')) as bashrc:
aliases = []
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()
aliases.append((source, target))
c.AliasManager.user_aliases = aliases
@zkiroel
Copy link

zkiroel commented Jul 15, 2015

what version of IPython i should use?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment