Mac OS 安裝 tmux
=
這是我之前的同事推薦使用的 session 管理器,覺得超酷,所以工作上都是使用 tmux。
安裝參考文章:
[終端機 session 管理神器 — tmux](https://larrylu.blog/tmux-33a24e595fbc)
# 安裝 brew
https://brew.sh/zh-tw/
安裝完成

加入環境變數
參考討論:[Setting PATH environment variable in OSX permanently](https://stackoverflow.com/questions/22465332/setting-path-environment-variable-in-osx-permanently)
```
sudo vim /etc/paths
```

# 安裝 tmux
```
brew install tmux
```
安裝完成

執行 tmux
```
tmux
```

# 設定 .tmux.conf
```
vim ~/.tmux.conf
tmux source ~/.tmux.conf
```
參考 tmux configuration
```
#=============#
#== Control ==#
#=============#
# mouse is great!
set-option -g mouse on
# Scroll History
set -g history-limit 30000
# set mouse select and copy
setw -g mode-keys vi
set -g set-clipboard off
bind-key -T copy-mode-vi v send-keys -X begin-selection
# bind y key in copy mode to select and copy to system clipboard
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "pbcopy"
# split windows
unbind %
bind v split-window -v
unbind '"'
bind h split-window -h
#==========#
#== KEYS ==#
#==========#
#using C-a as prefix
unbind C-b
set-option -g prefix C-a
bind C-a send-prefix
#==========#
#== Views==#
#==========#
set -g default-terminal "xterm-256color"
```
# 加入 .bashrc
為了之後 ssh 連入可以自動吃到 tmux config。

# 快捷鍵
* 水平分割:h
* 垂直分割:v
* 刪除分割:x
* 關閉tmux : d