Tmux
约 363 字大约 1 分钟
2025-10-21
Tmux
安装
debian/ubuntu
apt update
apt install tmuxalpine
apk update
apk add tmuxOh My Tmux
配置 tmux
依赖:
- awk
- perl(支持 Time::HiRes)
- grep
- sed
终端要求
- 支持真彩色
- 支持 OSC52
安装
依赖安装
glibc
sudo apt install perl grep sed gawk -ymusl
sudo apk add perl grep sed gawk ncurses-terminfo ncurses-terminfo-base安装oh my tmux
export OH_MY_TMUX_REPOSITORY="https://ghfast.top/https://github.com/gpakosz/.tmux.git"
curl -fsSL "https://ghfast.top/https://github.com/gpakosz/.tmux/raw/refs/heads/master/install.sh#$(date +%s)" | bash配置
以下这些配置可以使用脚本一键配置
curl -fsSL https://raw.githubusercontent.com/jianghuaangte/tmux-configs/refs/heads/main/tmux-conf-local.sh | sh
# 登录时不自动运行tmux
curl -fsSL https://raw.githubusercontent.com/jianghuaangte/tmux-configs/refs/heads/main/tmux-conf-local.sh | sh -s -- --no-autostartvi 模式
.zshrc
# 启用vi操作
echo 'export EDITOR=vim' >> ~/.zshrc禁嵌套、色彩支持
.zshrc
# 仅在外层终端设置 TERM
echo 'export TERM=xterm-256color' >> ~/.zshrc自启动
.zshrc
echo '
if [ -x "$(command -v tmux)" ] && [ -z "${TMUX}" ]; then
tmux new-session -A -s ${USER} >/dev/null 2>&1
fi' >> ~/.zshrc生效
source ~/.zshrc偏好设置
OSC52 复制
~/.config/tmux/tmux.conf.local
echo 'set -g set-clipboard on' >> ~/.config/tmux/tmux.conf.local
# linuxserver/openssh-server
echo 'set -g set-clipboard on' >> ~/.tmux.conf.local~/.config/tmux/tmux.conf.local
# 覆盖C-a
echo 'set -g prefix2 C-b' >> ~/.config/tmux/tmux.conf.local
# linuxserver/openssh-server
echo 'set -g prefix2 C-b' >> ~/.tmux.conf.local
# 覆盖延迟操作
echo 'set -sg repeat-time 10' >> ~/.config/tmux/tmux.conf.local
# linuxserver/openssh-server
echo 'set -sg repeat-time 10' >> ~/.tmux.conf.local显示中文
- 如果中文显示有问题
- 必须在 tmux 的
.zshrc配置之前
.zshrc
export LANG='zh_CN.UTF-8'
export LANGUAGE='zh_CN.UTF-8'
export LC_ALL='zh_CN.UTF-8'执行
sudo locale-gen zh_CN.UTF-8