Tmux 安装 & 配置

安装

依赖

  • tmux depends on libevent 2.x, and ncurses
  • To build tmux, a C compiler (for example gcc or clang), make, pkg-config and a suitable yacc (yacc or bison) are needed.
Platform Command Run
Debian apt-get install libevent; ncurses
RHEL or CentOS yum install libevent; ncurses

Tmux

Platform Install Command Version
Debian or Ubuntu apt install tmux 2.8
RHEL or CentOS yum install tmux 1.8
macOS brew install tmux

配置 Oh my tmux

Requirements:

  • tmux >= 2.3 (soon >= 2.4) running inside Linux, Mac, OpenBSD, Cygwin or WSL
  • awk, perl and sed
  • outside of tmux, $TERM must be set to xterm-256color

Install

To install, run the following from your terminal: (you may want to backup your existing ~/.tmux.conf first)

$ cd
$ git clone https://github.com/gpakosz/.tmux.git
$ ln -s -f .tmux/.tmux.conf
$ cp .tmux/.tmux.conf.local .

如果需要编辑你自己的配置,你可以修改 .tmux.conf.local 配置。

鼠标模式

这个配置默认没开鼠标模式,可以手动打开:

vim ~/.tmux.conf.local
# /mouse 回车
# 找到下面这一行:
# set -g mouse on
# 把前面的 # 去掉就好了

# 2.1版之前要开鼠标模式要输入4个命令
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on

# 2.1之后就只要一句就可以了
set -g mouse on

# github 上的版本 >= 2.2

# 然后在 tmux 里 
Ctrl+b
Shift+;
source-file ~/.tmux.conf
# 重新加载配置文件

vi模式

# force Vi mode
# really you should export VISUAL or EDITOR environment variable, see manual
set -g status-keys vi
set -g mode-keys vi

使用

  • 新建会话 tmux new -s name
  • 在 tmux 窗口运行所需的程序。
  • 按下快捷键 Ctrl+b + d 将会话分离。(可选)
  • 下次使用时,重新连接到会话 tmux a -t my_session
  • 水平分屏 <prefix> + %
  • 垂直分屏 <prefix> + "
  • 移动光标 <prefix> + o
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容