How do I make a shortcut bash script in Termux terminal android app?

How about using aliases?

nano/vi (or whatever you edit with) /data/data/com.termux/files/usr/etc/bash.bashrc

Add for each alias;

alias nodeapp='node storage/shared/folder_in_internal_android_memory/app.js'


You need to place the script in ~/.shortcuts/ and install the Termux:Widget app. Then Termux:Widget options appear in your homescreen launcher's widgets list.

Per nico's comment below, to access a typical launcher's widget list, long-press an empty space and tap the option that says "widgets" or "all shortcuts". Then find and long-press the desired Termux shortcut widget and drop it where you want.

Also note that Android lacks /bin and /usr/bin, so it is necessary to change LD_PRELOAD by running pkg install termux-exec and then restarting Termux.


Mark's answer got me on the right trail which is probably beyond the scope of what the OP asked for but I guess this might help other looking for some more automated solution:

The Termux:Task (com.termux.tasker) app allows to integrate execution of scripts into custom flows for tasker (and compatible, like Automate) programs.

Note that scripts to be executed need to be put to ~/.termux/tasker/ (folder also needs to be created).