安装

yum install tmux -y


配置

vi .tmux.conf

vi .tmux.conf

# ------ general ------------------------------------
set -g prefix2 C-s
bind C-s send-prefix -2

set -g escape-time 0
set -g base-index 1
set -g renumber-windows on
set -g mouse on
set -wg pane-base-index 1

# rename-window
set -wg allow-rename off
set -wg automatic-rename off

set -wg mode-keys vi

# last-window
bind a last

# retain current path
bind c new-window -c "#{pane_current_path}"
bind % split-window -h -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"

# restart and edit
bind r source ~/.tmux.conf\; display "tmux config sourced"
bind e neww -n tmux-config "\${EDITOR:-vim} ~/.tmux.conf"

# ------ move around --------------------------------
bind -r h select-pane -L
bind l select-pane -R # remove repeat, because of ls
bind -r j select-pane -D
bind -r k select-pane -U

# ------ status theme -------------------------------
set -g message-style "bg=#00346e, fg=#ffffd7" # tomorrow night blue, base3

set -g status-style "bg=#00346e, fg=#ffffd7" # tomorrow night blue, base3
set -g status-left "#[bg=#0087ff] ❐ #S " # blue
set -g status-left-length 400
set -g status-right "#{?client_prefix, ⌨ , } #[bg=#0087ff] #(whoami)@#h #[bg=red] %Y-%m-%d %H:%M "
set -g status-right-length 600

set -g set-clipboard on
set -g history-limit 8000

set -wg window-status-format " #I #W "
set -wg window-status-current-format " #I #W "
set -wg window-status-separator ""
set -wg window-status-current-style "bg=red" # red
set -wg window-status-last-style "fg=red"

set -wg pane-active-border-style "fg=blue"
set -wg pane-border-style "fg=#585858" # base01

# ------- copy to clipboard ------------------------
# bind -t vi-copy y copy-pipe 'xclip -selection clipboard > /dev/null'
# bind -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"


简化操作

vi /usr/local/bin/tm

#!/bin/bash

session=$1
[[ $session ]] || session=pair

[[ -d /tmp/tmux ]] || {
mkdir /tmp/tmux
# chown .team /tmp/tmux
# chmod 777 /tmp/tmux
}
sock=/tmp/tmux/$session.sock

if tmux -S /tmp/tmux/$session.sock ls 2>/dev/null; then
#tmux -f /etc/tm.conf -S $sock attach -t $session
tmux -S $sock attach -t $session
else
#tmux -f /etc/tm.conf -S $sock new-session -s $session "chgrp team $sock; zsh"
tmux -S $sock new-session -s $session
fi