I want to source my bash environment when executing a bash command from IPython using the !
operator, thus allowing me access to my defined bash functions:
In[2]: !<my_fancy_bash_function> <function_argument>
currently IPython is sourcing sh
rather than bash
:
In[3]: !declare -F sh: 1: declare: not found
How to source bash
and set my environment settings from IPython?
Linux commands and exercises are designed to be executed from a Linux terminal. However, there are several different ways that most of this functionality can be achieved from the Jupyter notebooks with the attendent advantage of built-in documentation capabilities.
Fernando Perez, creator of IPython, suggests this:
In [1]: %%bash . ~/.bashrc <my_fancy_bash_function> <function_argument>
This works on the current stable version (0.13.2). He admits that's a bit clunky, and welcomes pull requests. . .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With