
A-Shell: Terminal for iOS - _venkatasg
https://holzschu.github.io/a-Shell_iOS/
======
alexhutcheson
This is extremely cool.

Is there any documentation on what shell syntax this supports? I assume it's
not running a standard shell like Bash or zsh.

Edit:
[https://github.com/holzschu/ios_system/blob/master/README.md](https://github.com/holzschu/ios_system/blob/master/README.md)
confirms its not running sh, bash, or zsh, and has some additional details on
the available commands. I still think it would be nice for this to be more
explicit, but the information is out there.

~~~
kohtatsu
Very solid readme.

------
5-
LibTerm is very similar (also based on ios_system):
[https://libterm.app/](https://libterm.app/)

iSH uses a completely different approach -- it's a custom x86+linux emulator
that runs complete unaltered alpine linux userland:
[https://ish.app/](https://ish.app/)

~~~
GekkePrutser
Yeah I notice that even the websites of LibTerm and A-Shell are almost the
same. They use exactly the same icons for some items!

I assume one is a fork of the other?

~~~
aloknnikhil
Seems like both use this framework to generate the landing page

[https://github.com/emilbaehr/automatic-app-landing-
page](https://github.com/emilbaehr/automatic-app-landing-page)

------
jedisct1
I use iSH, that provides a complete Alpine Linux environment:
[https://ish.app](https://ish.app)

A-Shell seems to be very limited and additional packages cannot be installed.
What are uses cases for which A-Shell would be a better fit than iSH?

~~~
robenkleene
It’s in the App Store, for one.

~~~
softwarejosh
is that really valid here? i-sh is on testflight, the intersection of cant
figure out testflight and can use a terminal must be pretty low.

~~~
maxmcd
Isn't there an upper limit on the number testflight users?

~~~
saagarjha
Yes, 10,000. iSH is also distributed as an IPA that you can sign and install.

~~~
maxmcd
Do you need a paid apple developer account to sign and install it?

~~~
mmcwilliams
You can sign it with a free developer account, but I believe that you have to
re-sign every 7 days as opposed to every year with a paid developer account.

------
thesuperbigfrog
A-Shell looks very promising. If I were still using iOS, I would install it
and try it out in a heartbeat.

On Android, I love using Termux ([https://termux.com/](https://termux.com/)).

If I have a computer in my pocket, I should be able to use it as a computer,
not merely a consumption device

~~~
cft
Termux is awesome. Using it even made me order a foldable Bluetooth keyboard,
so i always have a dev environment in my pocket.

------
waynecochran
Great! I'm glad Apple has changed its rules concerning having an embedded
interpreter:

[https://news.ycombinator.com/item?id=14809096](https://news.ycombinator.com/item?id=14809096)

------
dmitshur
This was fun to try as a little preview of what it’ll feel like to have an
ARM-based MacBook.

Bummer there’s no git¹.

I was curious to try to install Go just to see how far I’d get before being
blocked. Was able to download the source tarball and extract it (using curl
and tar as 2 separate commands; piping curl into tar didn’t work). But then
can’t execute make.bash because there’s no bash.

[1] There's rationale and an alternative described at
[https://github.com/holzschu/ios_system#adding-more-
commands](https://github.com/holzschu/ios_system#adding-more-commands).

~~~
0x8BADF00D
If you really want an ARM64 based development platform, why not get a
Pinebook? Or something like the NVIDIA Jetson Nano? The philosophy of Apple is
to link against their officially provided frameworks/SDKs. It's not meant to
be a platform for open development.

~~~
cpach
macOS is still a quite an open platform.

~~~
oarsinsync
The context was ARM64 based platforms. macOS isn't on an ARM64 based platforms
(yet?).

~~~
cpach
Ah. My bad.

------
stblack
In this app, it appears we are operationally limited to

/private/var/mobile/Containers/Data/Application/49F47295-F9D8-4FD7-8F34-redactedxxxx/

The default folder is
/private/var/mobile/Containers/Data/Application/49F47295-F9D8-4FD7-8F34-redactedxxxx/Documents

I am able to cd / and can see the following folders

/Applications

/bin

/cores

/dev

/Developer

/etc

/Library

/private

/sbin

/System

/tmp

/usr

/var

... but can't cd into any of them. "permission denied".

None of this is a surprise, of course.

~~~
stblack
Odd there is no `which` command; this limits discovery.

`python --version` returns 3.7.1.

`curl --version` returns 7.54.0.

~~~
jagged-chisel
help -l

------
addajones
Terminus is excellent for iOS. [https://apps.apple.com/us/app/termius-ssh-
client/id549039908](https://apps.apple.com/us/app/termius-ssh-
client/id549039908)

------
liamcardenas
This may be a dumb question...

To my knowledge, the reason no “real” terminal exists for iOS is because it
violates the App Store rules. It is prohibited to download and execute
arbitrary code, with a few exceptions.

One exception is JavaScript, which must be run inside of JavaScript Core [1].
What if someone simulated x86 and Linux _in JavaScript_ and then built a
terminal and file system on top of it? Would that be in accordance with the
App Store rules (since it would be sandboxed in Apple’s JS core)? Would it
even be technically feasible? Or too slow for any serious usage?

[1] from the App Store rules:

4.7 HTML5 Games, Bots, etc. Apps may contain or run code that is not embedded
in the binary (e.g. HTML5-based games, bots, etc.), as long as code
distribution isn’t the main purpose of the app, the code is not offered in a
store or store-like interface, and provided that the software (1) is free or
purchased using in-app purchase; (2) only uses capabilities available in a
standard WebKit view (e.g. it must open and run natively in Safari without
modifications or additional software); your app must use WebKit and JavaScript
Core to run third-party software and should not attempt to extend or expose
native platform APIs to third-party software; (3) is offered by developers
that have joined the Apple Developer Program and signed the Apple Developer
Program License Agreement; (4) does not provide access to real money gaming,
lotteries, or charitable donations; (5) adheres to the terms of these App
Review Guidelines (e.g. does not include objectionable content); and (6) does
not offer digital goods or services for sale. Upon request, you must provide
an index of software and metadata available in your app. It must include Apple
Developer Program Team IDs for the providers of the software along with a URL
which App Review can use to confirm that the software complies with the
requirements above.

~~~
ajconway
It is not necessary to resort to JavaScript for the emulation, emulation and
interpretation are allowed. App Store effectively forbids the usage of JIT (so
VMs do not run as fast as one could expect) and running any code that’s not
included in the package at the time you submit the app for review (with an
exception for educational apps).

~~~
liamcardenas
I’m not doubting you, but I don’t see where in the App Store rules it forbids
JIT, other than the prohibition of running third-party code. Emulation and
interpretation are allowed — if the code is first- or second- party.

Educational apps are an interesting exception, but as I quoted in my patent
comment, JavaScript is the other major one.

So I wonder if JIT compilation and execution is possible under the rules _in
JavaScript_? (Again, is that even feasible?)

~~~
ajconway
Generally, JIT requires the ability to execute data (writeable memory pages
that contain code). iOS apps need a special system permission (in Apple's
terminology — entitlement) to construct such pages. To my knowledge, no apps
except for the first-party ones (like Safari) have this permission. Apps can
call into one system API that has this JIT capacity (WKWebView). It runs in a
separate process and uses IPC to communicate with the app. It has an API that
allows the application to execute arbitrary JS code at full speed. Some time
ago it lacked support for WebAssembly, but it may have been resolved by now.

So, these are the technical limitations of the platform. Apple chose to
implement a number of arbitrary rules on top of that. Well, it's not a
democracy, and they are free to do so. There is always a slight chance of
having some form of less restricted execution environment in future versions
of iOS, mainly due to how much their iPad Pro hardware is overpowered relative
to the OS capabilities.

~~~
mbreese
This was also discussed here a few months ago by the author of utmapp (Qemu on
iOS). In order to get their code to work, they need to effectively run their
own code in debugging mode. And yes, this requires the same entitlement as the
JS JIT.

[https://news.ycombinator.com/item?id=22387742](https://news.ycombinator.com/item?id=22387742)

------
vedosity
I was considering using lib-tex (the library implementing texlive 2019 for
this shell) last week for an iOS app I’m working on that needs to generate
basic LaTeX images. It’s really impressive, these programs running in A-Shell
are modified by renaming their `main()` function and making sure global/static
variables are cleaned up so they can run as a separate thread in-process
instead of spawning a separate process. I decided to use the more limited
KaTeX instead because it sounds like a maintenance nightmare, making sure
nothing leaks and updating everything every time a new version comes out...

I wonder if that process can be automated to a point where you could “lib-ize”
any C/C++ project (sed replacing malloc/free with something that cleans up
when the process “exits”, replacing exit/fork/etc, replacing static). I think
that would really open up the number of interpreters available on iOS.

------
thecybernerd
Is there any way I could use a USB C to DB9 console cable on an iPad Pro with
this? I’m thinking this could be a great setup for working in the cramped data
center.

~~~
s800
check into AirConsole. Works great, skip the cable. [https://www.get-
console.com/shop/](https://www.get-console.com/shop/) No relation.

------
jsjohnst
Why is the download so large I wonder? Almost 650mb app.

~~~
ken
"includes Python, Lua, JavaScript, C, C++ for programming and TeX (texlive
2019, including LuaTeX) for text processing."

I'm actually surprised it's only about 650 MB. TeX (Live) alone is huge.

~~~
jsjohnst
Lua is rather tiny. JavaScript and the _executor_ for C/C++ (as the compiler
compiles to WASM) are mostly Apple frameworks (JavaScript Core). Now Python
and Clang are fairly big, but not usually 650mb big, I’d say 200mb is more
likely. Now if TeX was included, totally agree, but as sibling comment
indicated, it’s not.

~~~
saagarjha
The compiler compiles to LLVM IR.

~~~
jsjohnst
From their own website:

> clang/clang++ _compiles your C /C++ files to webAssembly_ with wasi
> included. Executee the resulting files using 'wasm command'. You can also
> compile to webAssembly elsewhere and bring the files to your iPad.

~~~
saagarjha
Oh, oops, I mistook it for libterm, which has a very similar site…

~~~
jsjohnst
I _think_ they both share the same codebase, but not sure if there’s a
relationship between the two app publishers.

------
namelosw
I jailbreak several iOS devices just to have terminal many years ago, and it
was quite an interesting experience. I always hope Apple could let user access
terminal in iOS, at least in developer mode. After all, it's still BSD based
just like MacOS, and iPad Pro is so powerful but nowhere to go for a
programmer.

Sadly, it seems Apple doesn't really care about this.

~~~
kennywinker
This app is in the app store, so apple isn't actively blocking this kind of
thing anymore, which is an improvement!

~~~
namelosw
Indeed! I was just dreaming they could take even more steps :D

------
hyperpallium
Doesn't Apple ToS forbid programming (excepting embedded lua etc)? Did that
change?

Android 10 is locking down [http://termux.com](http://termux.com), and wifi
ipads have higher compute/$. If this works at full speed, I might get one.

~~~
krallja
No, Codea is a full featured Lua IDE for iOS, and there are lots of other
programming environments too. What they prohibit is compilation to native
code. If you have an interpreter (like lli, in this case), that’s fine.

~~~
kennywinker
That was not always the case. 2017 article about them easing restrictions on
this:
[https://www.theregister.co.uk/2017/06/07/apple_relaxes_devel...](https://www.theregister.co.uk/2017/06/07/apple_relaxes_developer_rules/)

~~~
lioeters
Wow, that was a few years back - I'm glad to learn about this change. Quoting
(and reformatting for better understanding) below..

\---

On June 5th of this year [2017], the Apple Developer Program License Agreement
(which applies to both the iOS and Mac App Stores) was revised to:

3.3.2 ..Interpreted code may be downloaded to an Application but only so long
as such code:

(a) does not change the primary purpose of the Application by providing
features or functionality that are inconsistent with the intended and
advertised purpose of the Application as submitted to the App Store,

(b) does not create a store or storefront for other code or applications, and

(c) does not bypass signing, sandbox, or other security features of the OS.

\---

An Application that is a programming environment intended for use in learning
how to program may download and run executable code so long as the following
requirements are met:

(i) no more than 80 percent of the Application’s viewing area or screen may be
taken over with executable code, except as otherwise permitted in the
Documentation,

(ii) the Application must present a reasonably conspicuous indicator to the
user within the Application to indicate that the user is in a programming
environment,

(iii) the Application must not create a store or storefront for other code or
applications, and

(iv) the source code provided by the Application must be completely viewable
and editable by the user (e.g., no pre-compiled libraries or frameworks may be
included with the code downloaded).

------
ulzeraj
It hangs if I run ssh-keygen or ssh-keygen -t ed25519. Tested on a recent ipad
pro and iphone x.

~~~
killerpopiller
same here. Is this a bug or can't ssh be used at all?

~~~
oddix
This is a known bug that the author appears to be implementing a fix for:
[https://github.com/holzschu/a-shell/issues/14](https://github.com/holzschu/a-shell/issues/14)

------
jlgaddis
Just this morning I realized I had a need for a decent SSH client for iOS,
although I don't need something that includes vim, clang, and Lua, Python, and
C, though.

That's extreme overkill for my needs -- I'd just like the ability to log in to
a few hosts (preferably using public key authentication!) and run various
commands just like I normally do in a terminal.

If anyone has any "favorites" they recommend, I'd be interested in hearing
about them. I'd prefer something open-source (out of principle) but I'm
certainly not opposed to paying a reasonable amount.

~~~
partlysean
How about Prompt from Panic?
[https://panic.com/prompt/](https://panic.com/prompt/)

~~~
stblack
Unless I'm missing something, Prompt can only connect to other servers.

This connects, in shell mode, to your iOS device.

~~~
mbreese
Isn't this more like a sandbox that lets you play in the sandbox with a CLI? I
don’t think it actually gives you shell access to your iOS device, just a
shell interface to its own program (and the other commands it supports).

------
ceocoder
This is very cool, over the years I've been using different apps - iSSH back
in 2010/2011 and Terminus lately - to connect to servers over ssh/mosh but
having a local working terminal would be great. Is there any way this can
update Apple Notes?

And

> "A text-based user interface for a screen-based platform"

Is that a play on "Limitless paper in paperless world" from a Dunder-Mifflin
ad?[0]

[0]
[https://www.youtube.com/watch?v=FIUSPM7xjAk](https://www.youtube.com/watch?v=FIUSPM7xjAk)

------
misrab
I'm seeing more and more dev tools being developed for mobile

e.g. yesterday on HN:
[https://news.ycombinator.com/item?id=22968079](https://news.ycombinator.com/item?id=22968079)

Seems like there's pent up demand for more hacker stuff on mobile! :) I wonder
what this could mean for the direction of the mobile paradigm (move towards
fewer walled gardens like app stores please?)

------
kgarten
I personally love Blink [https://blink.sh/](https://blink.sh/) it provides a
great mosh client.

~~~
strunz
Blink is great, but $20 for a terminal you might use occasionally or
emergencies is pretty stiff for me personally.

~~~
kgarten
It's free and opensource on github (if you register as developer for apple).

Edit: spelling error

~~~
strunz
Registering in the Apple Development program costs $99 (per year) too

~~~
847F5C7B
That is no longer true.

Registering for an account is free. you can get a signing key for testing
(i.e. to build and run on your own device) for free also. You only need to pay
if you want to publish to the App Store.

------
RodgerTheGreat
I can see that this tool in turn leverages ios_system, but neither A-shell nor
the ios_system github repository appear to present an exhaustive list of the
available commands. This seems like an obvious first step in improving
documentation.

~~~
qubex
Invoking “help -l” will give you a full list of available commands.

------
GekkePrutser
Nice!!!

What iOS really needs to make this useful though is a way to project to a
proper screen and keyboard/mouse configuration. Like Samsung DeX. Kinda hoping
this will happen as they are making the iPad Pros more like a computer.

~~~
djrogers
iPadOS supports this completely, as long as the application is written with
the external screen APIs in mind.

------
airstrike
Link to git repo
[https://github.com/holzschu/a-shell](https://github.com/holzschu/a-shell)

------
haddr
iSH is another good alternative, with alpine Linux and possibility to install
packages. Still in beta though

------
noodlesUK
How does this compare to ish? I know ish translates x86 into ARM on iOS. How
does this work?

~~~
FullyFunctional
It doesn't. It _interprets_ x86. There's a similar project to do this for
RISC-V, but it's not on TestFlight. I assume this pick the LLVM IR? It's an
interesting question what the optimal IR for this would be, but it would
probably be higher level than this, maybe more like WASM or the Zinc (O'Caml
IR).

~~~
saagarjha
The included commands for this are native code. The C compiler produces LLVM
IR.

~~~
FullyFunctional
I can't parse this, but the facts remain that the only JIT Apple allow is
their own. Any other app cannot generate and run native code at runtime. Thus,
apps are interpreting the immediate form (for iSH that 32-bit x86 and for
A-Shell it's LLVM IR).

iSH is threading, that is, the x86 code is translated into an IR consisting of
pointers to the code that executes its interpretation. This is a technique
older than FORTH and which may be the best you can do on iOS currently.
A-Shell may do the same, I don't know.

EDIT: updated with more details.

------
letmelurkaround
This is a great tool.

Love it

