How do I make a shortcut bash script in Termux terminal android app?
I had to resort to using Termux since the developer of Servers Ultimate Pro has not been updating the Node.js package for a long time and the new ES6 features are breaking my scripts. After browsing instructions, I've got latest Node.js installed through apt-get and I can run my script.
However, I have to type:
$node storage/shared/folder_in_internal_android_memory/app.jsIf possible could I make a bash script called "bot.sh" with:
#!bin/bash
node storage/shared/folder_in_internal_android_memory/app.jsThen run with:
$botI can cp an already created script but I don't know where to place it to allow me to shortcut it.
4 Answers
How about using aliases?
nano/vi (or whatever you edit with) /data/data/
Add for each alias;
alias nodeapp='node storage/shared/folder_in_internal_android_memory/app.js'
8You 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).
Is there any way to run a command or root script via termux at boot on Android and bypass security settings for super user access.. If there was some way to access Android keychain and certificates and manipulate them when they run at boot with a script then you could possibly get root access but I am not sure how to code it
2