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
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容