您的位置:首页 > 其它

Tmux 相关笔记

2017-12-07 12:11 134 查看

Tmux 相关笔记

Tmux 安装

$ sudo apt install tmux


Tmux 基础命令

prefix 默认为 ctrl+b,配置文件中会修改为 ctrl+a

Session

// 新建Session
$ tmux new -s <session_name>

// 退出Session
快捷键 prefix, d

// 重命名Session
$ tmux rename -t <session_name_old> <session_name_new>

// 重命名Session(Session内部)
快捷键 prefix, $

// 杀死Session
$ tmux kill-session -t <session_name>

// 查看已有的Session
$ tmux ls

// 进入某个Session
$ tmux a -t <session_name>

// 在Session间切换
首先, 进入一个Session
然后, 快捷键 prefix, s
最后, 使用上下箭头选择Session, 回车进入


Window

// 新建窗口
快捷键 prefix, c

// 关闭当前窗口, 会关闭所有pane
快捷键 prefix, &

// 重命名当前窗口
快捷键 prefix, ,

// 切换到上一个窗口
快捷键 prefix, p

// 切换到下一个窗口
快捷键 prefix, n

// 切换到编号为 <num> 的窗口
快捷键 prefix, <num>


Pane

// 左右pane
快捷键 prefix, %

// 上下pane
快捷键 prefix, "

// 关闭当前pane
快捷键 prefix, x

// pane间切换
快捷键 prefix, ↑、↓、←、→


Tmux 配置文件

$ vim ~/.tmux.conf


# 把 ctrl+b 前缀快捷键改为 ctrl+a, 方便单手操作
set-option -g prefix C-a
unbind-key C-b

# 按两次 ctrl+a 执行原意ctrl+a
bind-key C-a send-prefix

# 按住 alt 键, 使用箭头控制pane选择
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# 按住 shift 键, 使用箭头控制 window 选择
bind -n S-Left previous-window
bind -n S-Right next-window

# 开启鼠标支持, 使用鼠标直接选择 window 和 pane, 以及调整 pane 大小
# before tmux version 2.1
# set -g mode-mouse on
# set -g mouse-resize-pane on
# set -g mouse-select-pane on
# set -g mouse-select-window on
# tmux version 2.1 and later
set -g mouse on

# 前缀+v, 左右分屏, 前缀+h, 上下分屏
bind-key v split-window -h
bind-key h split-window -v

# Session内直接按前缀+r, 重新加载配置文件
bind-key r source-file ~/.tmux.conf \; display-message "tmux.conf reloaded"

# 把window和pane的起始下标设为1,因为键盘的0在9后面,切换不方便
set -g base-index 1
set -g pane-base-index 1

# UI样式调整
# 状态栏中window标签的高亮样式,默认绿底黑字,设置为红底白字显示
setw -g window-status-current-fg white
setw -g window-status-current-bg red
setw -g window-status-current-attr bright

# 状态栏中window列表左对齐排列
set -g status-justify left

# 非当前window有内容更新时显示在状态栏
setw -g monitor-activity on
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息