Termux

字数 1007 · 2021-08-04

Install

Fdroid 下载最新版

  • Termux
  • Termux:API
  • Termux:Styling
  • Termux:Boot
  • Termux:Widget

https://termux.com/

Repo

1
2
# 使用方向键和空格控制
termux-change-repo

Extra-Keys

~/.termux/termux.properties

1
2
3
4
extra-keys = [ \
  [{key: ESC, popup: KEYBOARD},{key: '-', popup: '|'},{key: '{', popup: '}'},{key: '[', popup: ']'},{key: '(', popup: ')'},{key: '/', popup: 'BACKSLASH'},'~','UP',':'], \
  ['TAB','CTRL','ALT','#','*','`','LEFT','DOWN','RIGHT'] \
]

Storage

termux-setup-storage

storage folder in home.

zsh

1
2
apt install zsh git
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

https://github.com/ohmyzsh/ohmyzsh

theme

1
2
3
4
5
6
7
8
9
# base on robbyrussell
NEWLINE=$'\n'
PROMPT='${NEWLINE}%{$fg_bold[cyan]%}%c%{$reset_color%} $(git_prompt_info)'
PROMPT+="${NEWLINE}%(?:%{$fg_bold[green]%}❯:%{$fg_bold[red]%}❯) "

ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"

vim

1
2
3
4
5
6
pkg add neovim
pip install pynvim
# copy .vimrc -> ~/.config/nvim/init.vim
# insall Plug
vim +PlugInstall
# in vim run :CocInstall coc-json coc-tsserver coc-emmet coc-jedi

ssh

1
2
3
4
# termux
pkg install openssh coreutils
whoami
sshd
1
2
# client
ssh -p 8022 user@127.0.0.1

Crontab

1
2
3
4
pkg install cronie termux-services
# restart termux
sv-enable crond
crontab -e 
1
export VISUAL=vi
0 9,17,22 * * * python $HOME/rss.py

https://crontab.guru/

node

1
2
pkg add nodejs
npm install -g yarn

ruby

1
2
pkg add ruby
gem install bundle

jekyll

1
2
3
4
pkg install ruby clang make pkg-config libxslt
gem install nokogiri --platform=ruby -- --use-system-libraries
bundle update
bundle exec jekyll serve

https://nokogiri.org/tutorials/installing_nokogiri.html

python

1
pip install ipython

nginx

1
pkg add nginx

cannot open privileged ports(<=1024) as non-root

Others

1
2
3
4
5
6
pkg add ripgrep
pkg add bat
pkg add git-delta
pkg add dust
pkg add nmap
pkg add exiftool

Addons

https://wiki.termux.com/wiki/Addons

style

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

API

Download add-on: Termux:API

1
pkg install termux-api
1
cat file.txt | termux-clipboard-set
  • termux-notification
  • termux-share

https://wiki.termux.com/wiki/Termux:API

Widget

1
mkdir -p $HOME/.shortcuts/tasks
1
chmod +x yourscript.sh

https://wiki.termux.com/wiki/Termux:Widget

Boot

~/.termux/boot/startup.sh

1
2
#!/data/data/com.termux/files/usr/bin/zsh
source $PREFIX/etc/profile.d/start-services.sh

https://wiki.termux.com/wiki/Termux:Boot

Packages

  • termux-am - activity manager
  • termux-services - run services
  • termux-tools - basic system tools for termux
    • termux-change-repo
  • science-repo
    • Geometry, Algebra, etc.
  • game-repo
    • Nethack

termux-am

可以发送任意 Intent,如 broadcast

1
2
3
4
am broadcast -a org.kustom.action.SEND_VAR \
--es org.kustom.action.EXT_NAME "termux" \
--es org.kustom.action.VAR_NAME "test" \
--es org.kustom.action.VAR_VALUE "hello"

termux-services

runit

1
2
3
4
# sv up <services>
# sv down <services>
# sv restart <services>
# sv status <services>

custom services

1
2
mkdir -p $PREFIX/var/service/<PKG>/log
ln -sf $PREFIX/share/termux-services/svlogger $PREFIX/var/service/<PKG>/log/run

and then put your run script for the package at $PREFIX/var/service/<PKG>/run and make sure that it is runnable.

1
2
3
4
#!/data/data/com.termux/files/usr/bin/sh
JEKYLL_HOME="/storage/emulated/0/jekyll-home"
cd $JEKYLL_HOME
exec bundle exec jekyll serve 2>&1

https://wiki.termux.com/wiki/Termux-services

play-audio

1
while true; do play-audio "Lights by Journey.webm" ;done

OpenSL ES - Open Sound Library for Embedded Systems

https://github.com/termux/play-audio

game-repo

Rogue-like

  • angband
  • brogue
  • moria
  • nethack

Interactive Fiction

Others

  • moon-buggy - drive a car across the moon
  • myman - Pac-Man
  • pacman4console
    • pacman
  • nsnake
  • tty-solitaire
    • ttysolitaire
  • vitetris
    • pkg add libx11
    • tetris

adb

https://github.com/rendiix/termux-adb-fastboot

am

pm

Toybox

0BSD licensed BusyBox alternative.