HomeAboutPostsTagsProjectsRSS

A-Shell

Updated
Words603
TagsRead1 minute

RoutineHub • Elevate Mobile Coding Together with Apple Shortcuts amazing resources for iOS shortcuts, one thing particularly useful is that the website can browse by App. Those shortcuts that use Scriptable on the App Store and a-Shell mini on the App Store Truly elevate automation capabilities on iOS to a new level. By combining these tools, you can accomplish complex tasks entirely on your iPhone.

a-shell notably supports Python, which is relevant given Python’s ongoing discussions about adding Tier 3 support for the iOS platform in version 3.13. PEP 730 .

The focus is on “embedded mode”, since there are no stdout on iOS and you can’t provide things like the Python REPL

What’s up Python? iOS support, ruff gets black, flask 3.0…

Updated
Words76
TagsRead1 minute

When using the a-shell action in iOS Shortcuts to execute shell commands or Python scripts, it is often necessary to wait for the execution to finish before continuing to execute other actions.

This can be achieved by using the open shortcuts:// command as the last step in the a-shell action and adding a Wait for Return action afterwards. This combination allows for waiting until a-shell finishes executing a long-running process before proceeding with other actions.

Updated
Words328
TagsRead1 minute

As of the time of writing, the current version of A-Shell is 1.12.1.

Passing Python Files to A-Shell

When using the iOS shortcut action A-Shell , the Put File action does not provide an option to specify the filename. Instead, it automatically names the file based on the first line of th content, excluding special symbols.

Base on this observation we can use the first line to specify filename and modify it after the file creation.

Let’s consider the following content.

getgif
import sys

if __name__ == "__main__":
    # print the first command line argument
    print(sys.argv[1])

it will be named getgif.txt after being passed from the “Text” action into A-Shell put file action

Removing the First Line with Sed

To remove the first line of a file (in this case, getgif.txt), we can utilize the Execute Command shortcut action in A-Shell. The command we can use is

sed -i '' '1d' getgif.txt

Executing the Python Script

Once we have removed the first line of the file, we can proceed to execute the Python script within A-Shell using Execute Command

python getgif.txt "hello"