Termux is a proper Linux distro running inside your Android, and it's amazing.
I got a call from a client yesterday who urgently needed me to edit a source file and push it up to GitHub. One problem: I was away from my apartment and wasn't carrying my laptop.
I did have my Nexus 7 with me. So, I tried a few things:
1. Chrome Remote Desktop to my laptop, but that was a bust, as my laptop had gone to sleep.
2. SSH (via the JuiceSSH app) to my server. So, I'm an Emacs user. I can do
vi/vim—a system administrator learns how to do everything
using just the base loadout of systems when necessary (and often less than that, as when the system is totally overloaded or out of storage—hell, I can even wrangle a system without a working terminal, I first learned Unix in "glass teletype" line-oriented mode)—but over text-only SSH using the Nexus 7 (and the indispensible Hacker's Keyboard input method (https://goo.gl/hMoaC
), which provides arrow, control, escape and tab keys), navigation through the source code was super painful. Maybe, if I were a vi guy and could remember all the various ways to navigate it would have been easier, but it wasn't going well¹.
3. So I got a native Android Git app and tried to use an Android text editor, but²
a) the text editors for Android I've seen are kind of like nano—designed for people who are scared of real source code editors—and didn't have simple features like regex find-and-replace, indention-aware reflow, or even end-of-line markers;
b) without experimentation I didn't have time to do (If I had time, I just would have gone back home to use a real computer!), I couldn't be sure the Git app would work properly with things like commit message formats and branch rebasing; and
c) the Android Git apps that are highly rated on the Play Store (and for all I know, all of them) don't support cert-based authentication to GitHub, so even if I could
edit the file, I couldn't push it up.
Then, while searching for a better editor (I figured, worse case, I could SCP the edited file and use git over the command line via SSH to push it up), I saw Termux in the "Users also installed". I was initially going to pass it by—I have an Android terminal emulator I like perfectly well when I need to dive into the backstage Linux OS on my Androids—but then I noticed it had a 4.8 rating (which, if you don't know, for a hard-tech app on the Play Store, is ridiculously
I took a look at the Play Store description. Well. It's obviously
overselling itself—Android can't do these things!—but I downloaded it. Started it up, and had a terminal, like the other terminal apps. But. First of all, I was in bash
, not the hobbled Android /system/bin/sh³. Second, after trying a few commands, it—like Debian-derived Linux distros on big-boy boxes—invited me to install the software with apt install
Feeling a little foolish at wasting this time, and sheepish for going along with the gag, I typed apt install vim openssh git zsh
and hit enter. Well, it certainly did an acceptable job of simulating
the download and installation of Debian packages and dependencies (complete with ANSI colors and ncurses progress bar!)... I pulled my SSH key into a file in .../Downloads
using JuiceSSH, copied it into ~/.ssh/
in Termux and did an "ssh-add". Then I did a "git clone". Right after I hit enter I immediately thought, "wait! I should have limited the clone history! On Android this is going to take forev...oh, it's done."
I ran vim on the file (cheekily, I thought, after running echo "set number\nset ignorecase" > ~/.vimrc
), and glory be! Fully colorized, syntax highlighted, line-numbered source code. "Oh, but this is still going to be annoying to navigate around," I thought. Finding one spot to edit, I pecked at the Hacker's Keybard, made my first change, then hit the down arrow a couple times and realized I left out a character. In vim, getting back to that point to fix it using the keyboard would be half a dozen keystrokes, which, on a touchscreen keyboard, isn't nothing. Counting characters to see if using the column number would be faster than the other method for getting the cursor back where I wanted it, I happened to tap the screen... and the cursor jumped to where I'd tapped
I discovered that not only has Termux cleverly handled terminal "mouse" events for clicking to reposition the cursor, it intercepts swipes and turns them into scrollwheel events. So now, to make my fixes, I just had to slide the source code file and tap where I wanted to edit, just as if it were a native Android document in a native app! Yeah, I know; it is
a native Android document in a native app (or program in an app, anyway). But that was how weird this felt—like I wasn't really
in Android's Linux plumbing layer, but in a beautiful simulation of a Linux PC running within my Android tablet as if it were a VM.
I saved, ran my lint checks, code prettifier, and tests — on Android
(after a couple more apt install
and scripting-language library installs) — and did a git push
. Voilà! I called my client and told him to check GitHub. Done!
And it's taken me longer to write this up than the whole thing took—it was so intuitive to anyone who's comfortable with Linux that there's no
learning curve—the only thing I had to look up in the documentation was where to find the Android Downloads
folder in the Linux filesystem Termux presents. It was definitely so
much faster than trying to do it with Chrome Remote desktop, over SSH, or with Android editors and Git clients that the time spent installing it and the prereqs were less than the time I would have spent struggling with native apps.⁴
I recently got my dotfiles working feature-complete across Mac, Ubuntu Linux, and Raspbian (Debian for Raspberry Pi). And amazingly, my dotfiles under Termux just worked once I installed a few missing prerequisites. (Only thing missing was hub, the GitHub helper app. Creating a symlink from hub in my PATH to git made things work again. I'll have to see about building a hub deb for Android. Another neat thing about Termux: if you're willing to wait for a computer about as fast as a 2008 desktop and can plug in, there's no reason you have to cross-compile Android targets; gcc and golang are just one apt install
Okay, I'm gushing, but with reason. Termux is just awesome
. If you're a Linux person and have an Android tablet (or phablet—even a 5″ phone could even be useful if you're patient with the tapping), go get it, now.
¹ Why not Emacs over SSH? I'm an Emacs lover, but the multikey control- and meta- sequences, though powerful, are a total impedance mismatch with a tap-based keyboard on a device too small to permit modifier chording. I've done Emacs on a 10″-plus tablet before, where you can chord, and it's just fine, though it'd be difficult if you had to hold the device while you worked.
² Before people come out of the woodwork to tell me about the apps I missed: I wouldn't be surprised if I could
find an editor and Git app that meet these needs, but Termux is still better; read on.
³ Of whose provenance I'm totally unaware—anyone know where it came from? It isn't ash
, or the busybox shell (at least, of the busyboxes I'm familiar with).
⁴ In all honesty, using vim over the SSH to my server in the first place would probably
have ended up taking about the same amount of time—but installing Termux and setting it up is amortizable time, while struggling with vi navigation wouldn't have been.