482 字
2 分钟
Termux配置教程
1、下载Termux并安装:
https://github.com/termux/termux-app/releases
2、目录结构:
echo $HOME/data/data/com.termux/files/home
echo $PREFIX/data/data/com.termux/files/usr
echo $TMPPREFIX/data/data/com.termux/files/usr/tmp/zsh3、更换国内源
sed -i 's@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/termux-packages-24 stable main@' $PREFIX/etc/apt/sources.list
sed -i 's@^\(deb.*games stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/game-packages-24 games stable@' $PREFIX/etc/apt/sources.list.d/game.list
sed -i 's@^\(deb.*science stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/science-packages-24 science stable@' $PREFIX/etc/apt/sources.list.d/science.list
pkg update4.安装基础工具
pkg updatepkg install vim curl wget git tree -y5.终端配色方案
该脚本主要使用了 zsh 来替代 bash 作为默认 shell,并且支持色彩和字体样式,同时也激活了外置存储,可以直接访问SD卡下的目录。
项目地址:https://github.com/Cabbagec/termux-ohmyzsh/
sh -c "$(curl -fsSL https://github.com/Cabbagec/termux-ohmyzsh/raw/master/install.sh)"出现网络超时的情况,则需要梯子,脚本运行后先后有如下两个选项:
Enter a number, leave blank to not to change: 14Enter a number, leave blank to not to change: 6输入14和6分别选择 色彩样式 和 字体样式 ,重启Termux后生效配置。
想要更改配色方案的话,可以根据下面命令来更改对应的色彩配色方案:
- 设置色彩样式:输入
chcolor命令更换色彩样式,或者执行~/.termux/colors.sh命令 - 设置字体:运行
chfont命令更换字体,或者执行~/.termux/fonts.sh命令 脚本执行中Android6.0 以上会弹框确认是否授权访问文件,点击始终允许授权后Termux可以方便的访问SD卡文件。 点了拒绝的话,那么可以执行以下命令来重新获取访问权限:
termux-setup-storage6、隐藏localhost用户名:
在 home 目录下:
vim .zshrc将以下代码添加至末尾:
prompt_context() {if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; thenprompt_segment black default "%(!.%{%F{yellow}%}.)$USER"fi}8、创建目录软连接
执行上面的配置脚本后,并且授予Termux文件访问权限的话,会在 Home 目录生成 storage 目录,并且生成若干目录,软连接都指向外置存储卡的相应目录:
为了方便文件传输和管理,在直接在 storage 目录下创建软链接.
ln -s /data/data/com.termux/files/home/storage/shared/java文章分享
如果这篇文章对你有帮助,欢迎分享给更多人!
最后更新于 2022-05-10,距今已过 1625 天
部分内容可能已过时
岁语集