sudo yum -y install tmux # centos
sudo apt install -y tmux # ubuntu
2. 执行这个命令 生成一个脚本 放在用户目录里
.reuse_session.sh
cat <<EOF > ~/.reuse_session.sh
if [ ! -n "\$TMUX" ]; then
tmux a -t "\$USER" > /dev/null
if [ "\$?" -ne 0 ]; then
tmux new -s "\$USER"
fi
exit
fi
EOF
3. 把脚本添加到登录脚本里
# bash用户加 .bash_profile
echo '. ~/.reuse_session.sh' >> ~/.bash_profile
# zsh用户加 .zprofile
echo '. ~/.reuse_session.sh' >> ~/.zprofile
6. tmux配置文件
cat <<EOF > ~/.tmux.conf
set -g default-terminal "xterm-256color"
bind '"' split-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"
set -g mouse on
EOF
配色使用xterm-256
分屏保留路径