Skip to content

Instantly share code, notes, and snippets.

@solidpple
Last active March 16, 2018 06:28
Show Gist options
  • Save solidpple/b130c042bf8402ad152b6744facc7b52 to your computer and use it in GitHub Desktop.
Save solidpple/b130c042bf8402ad152b6744facc7b52 to your computer and use it in GitHub Desktop.
# /home/username/.ipython/profile_default/startup/alias.py
import subprocess
lines = subprocess.check_output('source bashrc; alias',shell=True).split(b'\n')
manager = get_ipython().alias_manager
for line in lines:
line = line.decode("utf-8")
split_index = line.find('=')
cmd = line[split_index+1:]
alias = line[:split_index]
cmd = cmd[1:-1]
print ("ALIAS:{}\t\tCMD:{}".format(alias,cmd))
manager.soft_define_alias(alias, cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment