Skip to main content

Android Termux Native Dev Env Setup — Your Android is not Only an Android

·706 words·
Table of Contents

I have post an article about installing archlinux and vscode in termux last time. Howerver, It’s not so good as I thought. But I have learn it in detail after that time, and now I know there is a better way to use it – just use its native software ecosystem. If you have got your Android device rooted, well, there is a better way to use it, but now let’s just focuse the native one.

Mark Please install Termux from github. Don’t install it from play store, which is not updated.

1. The New World
#

The package manage system of Termux is derived by debian’s APT, but there is only few packages to be availiable. However, TUR, which is similar to Archlinux’s AUR, gives more packages. To enable it (and other repos):

pkg update
pkg install tur-repo x11-repo root-repo

2. Configure the Development Environment for Termux
#

Now it’s time to use our imagination to configure it. But let’s install some basic tools first:

pkg install neovim git curl wget lsd

Access Storage
#

Grant Storage access:

termux-setup-storage

Then visit ~/storage to access Android’s Internal Storage. You can also use cd /storage/emulated/0.

If the device has SD Card, use cd /sdcard to access the SD Card. You would create a soft link by

ln -s /sdcard ~/sdcard

Mark Different Android system may has different path. In Samsung Tab, it’s path is /storage/<SD Card ID>. You can useRoot Explorer APP to find it.

Make Termux More Beautiful
#

It’s suggested that zim is more powerful than oh-my-zsh. But for Termux, it’s better to use oh-my-zsh for its compatibility. However, I will give the zim tutorial. oh-my-zsh is much more simple.

pkg install zsh
# install zim
curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh

Install powerlevel10k theme, add zmodule romkatv/powerlevel10k --use degit to ~/.zimrc. Meanwhile, comment zmodule zsh-users/zsh-syntax-highlighting in .zimrc(If don’t do this, zsh would warn you. Maybe there is no package that it needs in Termux).Then run zimfw install. Then, run the following command(also warn if don’t do this).

echo '(( ! ${+functions[p10k]} )) || p10k finalize' >>! ~/.zshrc

To reconfigure p10k theme, run p10k configure.

make ls beautiful: add alias ls=lsd to .zshrc.

Google Cloud CLI
#

pkg install wget curl which
curl https://sdk.cloud.google.com | bash

# to login
gcloud auth login

Programming and Tools
#

It is would be myriad. The following are some of commonly used.

Python3
#

pkg install python3 python-pip

go
#

pkg install golang

# look at the version, it's the newest one
go version

rust
#

rustup is not availiable there.

pkg install rust

C, C++
#

pkg install clang 

nginx
#

You may use IPv6 to let others visit your web server.

pkg install nginx

Mark /etc is located at /data/data/com.termux/files/usr/etc, and you can access it by cd ../usr in ~(your home dir).

hugo
#

pkg install hugo

# It's also the newest version
hugo version

My blog is made by hugo, and now I can preview my blog vith the help of Termux. You can type http://localhost:1313 in you browser in Android system to visite the web page after running hugo server in Termux.

code-server
#

pkg install code-server

Configure code-server:

nvim ~/.config/code-server/config.yaml

I would recommend you that make auth to be none, so that you can enter vscode more convenient. run code-server:

code-server

Visit by http://localhost:8080 in your Android browser. It’s a pitty that there are lots of plugins that are not availiable in code server.

Desktop Environment - xfce4
#

First, we need install Termux-X11 APP from there, most Android device is arm64.

Then, install the following packages:

pkg install x11-repo termux-x11-nightly pulseaudio xfce4

To visit your desktop, open your Termux-X11, and run the following command in Termux

bashtermux-x11 :1 -xstartup "dbus-launch --exit-with-session xfce4-session"

You may also refer there When finished it, you can install some themes and fonts. You can follow this video:

native vscode - code-oss
#

pkg install code-oss

3. Run Windows Program
#

You may try Wine or Mobox. But I think it’s not such useful, because Android and Termux are powerful enough.

End
#

Termux is a good choice to those who want to learn Linux. And for those who are looking forward to Android tablet productivity, it worth a try.