2

I mean like it is when user opens an image file a pane opens where user can select app for given type. But when I'm clicking on *.sh file the first option that shows up is to open as text/audio/video/image and when I'm choosing to open it as text there is no terminal app in the list. I've installed Xposed framework but this app only allows to remove some of the apps from the list but I cannot find an option to add a terminal to *.sh file as allowed app.

What I mean is it to be like on desktop operating systems where a console shows up and prints and executes all the commands in file.

Now what I do is:
1. open *.sh file in text editor.
2. select all the code
3. copy to clipboard
4. open terminal app
5. paste code into terminal
6. don't forget to press enter to execute last line of the text that was pasted

  • You need both a File Manager that fires an intent to open a .sh file, and a terminal app that registers as a handler for such files. – Matthew Read Mar 5 '15 at 0:05
1

Matthew Read is right in the comments, but you can still have a workaround for the goal.

Tasker offers a "Task Shortcut" feature that can be used to place shortcuts on home screen. You can use this feature to place task shortcuts for your scripts on home screen, if not in file manager. Many Launcher app nowadays allow folder creation on home screen so you can place and pack as many shortcuts as you like.

Instructions

  1. To add a Task shortcut, go into Widget selection in your default launcher and choose Task Shortcut.
  2. Enter a name which would be the name of the shortcut → +Code → Run Shell.
  3. Enter the details as per your needs. You may either paste the code into Command field, or type sh <SCRIPT_FILEPATH> where <SCRIPT_FILEPATH> should be your script's location.

    Use Root if necessary. Save the errors or results into variables (can write into files too) because unlike desktop OS, nothing like launch of terminal window, printing of standard output ,and then auto closing of that window is going to happen here.

  4. Save the task (pressing back key once saves things in Tasker).
  5. Choose an icon and come back to home screen.
  6. Tap the shortcut and it would now execute. Place as many shortcuts as you want. Also, you can execute those shortcuts as long as Tasker's service is running in background, which it would be unless you disable it manually or system force-closes it.
| improve this answer | |
0

Use Root Explorer. It shows a dialog when you tap a shell file, asking you to choose an option from three: Execute, View and Cancel. That's what you want.

There's also a free (without root capabilities) version.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.