如何从应用程序在 termux 中启动脚本

How to start a script in termux from an app

我需要在我的 android 平板电脑上的 termux 环境中从其他 android 应用启动脚本。我觉得应该有两种可能。

  1. 在 termunx 中设置某种启动脚本(例如 bash shell 中的 ~/.bashrc)并从其他应用程序启动 termux
  2. 使用脚本名称作为参数从其他应用调用 termux,以便 termux 立即执行该脚本。

我不知道如何做这两种可能性。 有谁知道如何实现它,也许是第三种方法,我到目前为止还没有想到?

只见树木不见森林。答案正是我第一个建议的方式。我没有意识到,bash 是 termux 中的默认 shell。所以只需 .bashrc .profile .bash_profile 之一即可完成工作。