Created
April 27, 2014 18:26
-
-
Save bfontaine/11352254 to your computer and use it in GitHub Desktop.
Import your ~/.bashrc aliases in IPython
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what version of IPython i should use?