Termux in a nutshell
Tags: termux, linux
Published: 2020-09-16 22:08:19

# termux

According to Termux official site

> Termux is an Android terminal emulator and Linux environment app that works directly with no rooting or setup required. A minimal base system is installed automatically - additional packages are available using the APT package manager. 


### Features

- Secure. Access remote servers using the ssh client from OpenSSH. Termux combines standard packages with accurate terminal emulation in a beautiful open source solution.

- Feature packed. Take your pick between Bash, fish or Zsh and nano, Emacs or Vim. Grep through your SMS inbox. Access API endpoints with curl and use rsync to store backups of your contact list on a remote server.

- Customizable. Install what you want through the APT package management system known from Debian and Ubuntu GNU/Linux. Why not start with installing Git and syncing your dotfiles?

-  Explorable. Have you ever sat on a bus and wondered exactly which arguments tar accepts? Packages available in Termux are the same as those on Mac and Linux - install man pages on your phone and read them in one session while experimenting with them in another.

- With batteries included. Can you imagine a more powerful yet elegant pocket calculator than a readline-powered Python console? Up-to-date versions of Perl, Python, Ruby and Node.js are all available.

- Ready to scale up. Connect a Bluetooth keyboard and hook up your device to an external display if you need to - Termux supports keyboard shortcuts and has full mouse support.

- Tinkerable. Develop by compiling C files with Clang and build your own projects with CMake and pkg-config. Both GDB and strace are available if you get stuck and need to debug.

Credits: Termux Official Site at https://termux.com/


## God to know

- Termux is an Android terminal emulator and Linux environment application
- Termux is single-user
- Root file system is stored as ordinary application data
- Termux does not follow Linux Filesystem Hierarchy Standard unlike majority of Linux distributions. You cannot find directories like  `/bin, /etc, /usr, /tmp` and others at usual location.


## Common Softwares

```sh
pkg in git
pkg in nodejs
```

```sh
pkg in root-repo		# 
pkg in unstable-repo	#
pkg in x11-repo 		# x11
pkg in proot 			# use classical Linux file system layout
```

---

## Installing Zsh shell

```sh
pkg in zsh
```


### Ohh My Zsh - Basic Installation

Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either `curl` or `wget` should be installed

`git` should be installed (recommended v1.7.2 or higher)


via curl

```sh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

via wget

```sh
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
```

---

## Zsh Plugins 

1. zsh-autosuggestions

- Clone this repository into `$ZSH_CUSTOM/plugins` (by default `~/oh-my-zsh/custom/plugins`)
```sh
git clone https://github.com/zsh-users/zsh-autosuggestions \
${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
```
- Add the plugin to the list of plugins for Oh My Zsh to load (inside `~/zshrc`):
```ini
plugins=(zsh-autosuggestions)
```
- Start a new terminal session.



2. zsh-syntax-highlighting

- Download zsh-syntax-highlighting by

```sh
git clone https://github.com/zsh-users/zsh-syntax-highlighting.gitZSH_CUSTOM/plugins/zsh-syntax-highlighting
```

- `nano ~/.zshrc` find `plugins=(git)`

- Append `zsh-autosuggestions & zsh-syntax-highlighting` to  `plugins()` like this 

```ini
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
```

- Reopen terminal


### Ref
 - [oh-my-zsh](https://github.com/robbyrussell/oh-my-zsh)
 - [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions)
 - [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting)
 - [https://gist.github.com/kevin-smets/8568070](https://gist.github.com/kevin-smets/8568070)
 


----
## Termux Styling


```sh
cd ~ # change to Home Dir
git clone https://github.com/adi1090x/termux-style.git
```

- Change to cloned directory
```sh
cd termux-style
```

-  Make script executable
```sh
chmod +x setup
```

- Run setup to finally install it
```sh
./setup
```

Ref: https://github.com/adi1090x/termux-style


----
## Working with packages

### Installing packages from APT repository

In Termux it is recommended to use package manager `pkg` which is a wrapper for `apt`. 

>It simplifies installing or upgrading packages by automatically updating apt lists so you don't have to type apt update when installing or upgrading packages.



#### Install package:

```sh
pkg install package_name
```

#### Remove package:

```sh
pkg uninstall package_name
```

#### List all packages:

```sh
pkg list-all
```

#### Upgrading packages:

```sh
pkg upgrade
```


For more information about available commands you can either just run pkg without arguments or like this: `pkg help`.

---

### Manual installation of `*.deb` files

If you have a `*.deb` package file, you can install it with `dpkg`. 

>Note that packages downloaded from *Ubuntu or from repositories of other Linux distributions will not work due to incompatible libc ABI*, however statically compiled binaries may work.


#### Installing:

```sh
dpkg -i ./package.deb
```

#### Uninstalling:

```sh
dpkg --remove package_name
```

#### Listing all installed packages:

```sh
dpkg -l
```

Since dpkg has many useful options, you may want to see it's manual via `man dpkg`.

Ref: https://wiki.termux.com/wiki/Package_Management


---