Wednesday, March 3, 2021

在 macbook 下使用的 .tmux.conf 檔案

我有時候很佩服一些朋友,他們會把一些工具玩轉到極致,我的話,通常還是採取 purpose-driven 的方式去研究工具。確定會派得上用場的,才去做設定。下方是我平常用的 tmux config ,可以搞定我覺得對我來說比較重要的兩個功能:
  • 可以用滑鼠捲動。
  • 複製貼上可以與系統的剪貼簿整合。
------- 分隔線 -------

# Enable mouse scrolling
set -g mouse on

# Vim style navigation in copy mode
setw -g mode-keys vi
bind P paste-buffer
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'pbcopy'
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle


# Tutorial: copy-pase through tmux buffer
#
# default <prefix> is <C-b>
# using `<C-b> + [` to enter copy mode
# using `v` to start selection
# using `y` to copy selection
# it will get the text stored at two places: tmux copy buffer and system clipboard
# using `ESC` to clear selection
# using `q` to leave copy mode
# using `<C-b> + P` to paste at another tmux session