Setting up ZSH on Android
Tags: productivity, android, zsh, tutorial
Published: 2020-12-20 09:50:59

One day I was out and about seizing the day, when I suddenly saw on the news that a critical zero-day bug has been unleashed and I urgently needed to patch my servers, but I don't have my laptop with me! 

Has that ever happened to you? *Well me neither*, but **in case** you ever did, here's how you can setup a proper ZSH terminal on your Android device!

## What you need
1. `1 x Android device`
2. `1 x Internet Connection`
3. `2 x 1 min`

## Steps 🚶
```bash
# Step 1
pkg install zsh

# Step 2 (https://ohmyz.sh/#install)
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

```

Yeap that's all you need to get ZSH on your android device. For any other packages, you can use `pkg` or `apt-get`. Termux provides a slew of useful utilities by default, and you can expand upon that with Termux APIs; allowing you to do things like retrieving SMS, getting location, etc. You could use SMS as an out-of-band way of triggering a smart home action for example.

*Note that* in order to use Termux APIs, you first need to install from the Play Store, then run `pkg install termux-api`. Then make sure that the Termux API application has enough permissions to do what you want.

But wait, you don't like the limited Linux functionality that Termux provides you? [How about installing Ubuntu on your phone?](https://github.com/termux/proot-distro). Someone created [PRoot](https://wiki.termux.com/wiki/PRoot), which is a user-space implementation of `chroot`, which is what makes running Ubuntu on Android pretty easy and straightfoward (unlike the janky dual-boot script days).

## My setup 🤓
Having plain old vanilla ZSH is fine and all, but you can spice your life up with some useful plugins. To make installation easier, I rely on a plugin manager called [Antibody](https://getantibody.github.io/). To get started, follow the instructions on their site cause it's really well written.

Using the static loading method (because it's faster), this is my list of plugins in my `.zsh_plugins.txt` file.

```
zsh-users/zsh-completions
zsh-users/zsh-syntax-highlighting
zsh-users/zsh-history-substring-search
zsh-users/zsh-autosuggestions
mafredri/zsh-async
sindresorhus/pure
```

I think the plugins are pretty self-explanatory except for the last two, which is the theme that I use because it's minimalistic.

Two other plugins I use are
1. [autojump](https://github.com/wting/autojump): quickly switch between directories based on history (had to manually install)
2. [scmpuff](https://github.com/mroth/scmpuff): numbered git files and nice alises. I had to compile this, which forced me to install golang (it works!)

![Termux ZSH screenshot](https://dev-to-uploads.s3.amazonaws.com/i/l36acbe2o2f44cm6yuvm.jpg)

## My use case 🦄
Why go through all this effort to have a nice shell experience on Android? All of these was done to set me up for having a [Productive 2 weeks in reservist](https://blog.lordofgeeks.com/2020/12/productive-2-weeks-in-reservist/). I wanted to try if it is possible to develop on an Android Tablet.

> Spoiler: it worked bloody well

Article on developing on a tablet will be coming soon where I also share how it was also useful for making quick changes on my  [portfolio](https://lordofgeeks.com/) site, as well as miscellaneous SSH tasks on my VPS.

In summary, it's **really easy** to setup a decent shell experience on your Android devices these days (hint: iOS too 😏). Have fun!