bash - 从 IPython 执行 Bash 命令

标签 bash ipython

我想在使用 ! 运算符从 IPython 执行 bash 命令时获取我的 bash 环境,从而允许我访问我定义的 bash 函数:

In[2]: !<my_fancy_bash_function> <function_argument>

目前 IPython 正在采购 sh 而不是 bash:

In[3]: !declare -F
sh: 1: declare: not found

如何从 IPython 获取 bash 并设置我的环境设置?

最佳答案

Fernando Perez,IPython 的创造者,suggests this :

In [1]: %%bash
. ~/.bashrc
<my_fancy_bash_function> <function_argument>

这适用于当前的稳定版本 (0.13.2)。他承认这有点笨拙,并欢迎 pull requests . . .

关于bash - 从 IPython 执行 Bash 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15927142/

相关文章:

linux - 在多个文件中搜索多个模式

linux - 为什么这个 shell 管道会退出?

python - 用于 Python 的轻量级控制台/IDE?

python - 访问 Jupyter Notebook 中的根目录

python - 更改 ipython 中的输出字体

bash - 如何找到当前的 shell 命令

linux - 如何使用 Unix/Linux 命令计算韩文字 block ?

linux - Bash - 需要使用 exit 然后调用另一个函数?

python - 木星 pyspark : no module named pyspark

python - Google Collab 如何显示作业的值(value)?