How I Use Termux

Published: 2023-05-15
Last Updated: 2023-05-20

Termux is one of the more fun and useful applications you can install on any Android-based mobile device. For me, having a terminal emulator and Linux environment in my pocket makes my device feel infinitely more powerful and useful, almost as though I have a fully fledged computer that I own in my pocket as opposed to something locked down. Lately I've been using termux with my e-reader, turning it into a makeshift "writingdeck". In fact, this entire post was written in vim via Termux on my e-reader with a bluetooth keyboard. Here's are my notes on getting started with Termux.

Note that the Google Play version of Termux is no longer updated due to restrictions. Current versions of Termux is available on F-Droid and the GitHub repo.

Basic Commands

To set up storage access run termux-setup-storage. Once this is completed, the Termux 'home' directory will list shortcuts to common folders. 'Shared' will be the main Android user folder.

To install a package run pkg install [package name]. Most common Linux packages are available in the Termux repository, with the obvious exception of GUI programs like Firefox, GIMP, etc. Similarly, you can remove a packge with pkg remove [package name].

Some of the programs I've installed include: ranger, vim, calcurse, cmus, newsboat, mutt, w3m, neofetch (for fun), htop, man, sc, ffmpeg, pass, yt-dlp, p7zip, and bash-autocompletion.

Keyboard Shortcuts

Here are the default keyboard shortcuts.

Action Shortcut
Spawn new terminal CTRL+ALT+C
Rename session CTRL+ALT+R
Switch sessions CTRL+ALT+UP/DOWN (or CTRL+ALT+N/P)
Open/Close swipe out drawer CTRL+ALT+LEFT/RIGHT
Adjust text size CTRL+ALT++/-
Go to specific session CTRL+ALT+[number]
Select URL CTRL+ALT+U
Kill process CTRL+D

It's also possible to remap some of the shortcuts by editing the termux.properties file. I've set up mine so that it's somewhat consistent with the terminal shortcuts I use with kitty on my laptop.

Action Shortcut
Spawn new terminal CTRL+C
Switch sessions CTRL+h/l

Disable On-Screen Keyboard Shortcuts

I use a physical keyboard with Termux and don't have any need for the on-screen keyboard shortcuts like ESC, tab, etc. These keys also take up some screen real estate. To hide these shortcuts, edit the extra-keys parameter of the following line in the file .termux/termux.properties to look like extra-keys = [], then save changes, exit, and run termux-reload-settings.

Change theme

To change the default Termux theme, install the app Termux:Styling from F-droid. Once installed, long press anywhere on the screen, tap "More...", then tap "Style". For e-ink screens (my current use-case), flat-light and gray scale light both look fine.

Root Access

If you have root access on your device, you can access it via termux with a few additional packages.
pkg install proot proot-distro tsu fakeroot parted
Once installed, root can be attained by running su .

Launching Native Android Apps

The way my workflow is, I simply CTRL+Up/Down between terminal sessions. However, I sometimes find it easier to launch a native Android application from the terminal itself as opposed to tapping home and fumbling around through apps. termux-launch is a great tool for launching app from Termux.

For example, if I want to launch Fennec (F-Droid version of Firefox) I can simply run the command launch -a fennec. What I've done is set a bash alias for this so when I run fennec, it runs the termux-launch command launch -a fennec.

Resources

Thanks for reading. Feel free to send comments, questions, or recommendations to hey@chuck.is.