macos-tmux-vim-clipshare

在tmux session 里面,通过prefix+esc选中复制的内容是不会与 vim 自身的寄存器以及MAC OS 共享。
以下步骤可实现MAC OS tmuxprefix+ese以及 tmux中vim复制的共享

  • brew install reattach-to-user-namespace
  • edit your tmux conf file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Copy-paste integration
set-option -g default-command "reattach-to-user-namespace -l /etc/zsh"

# Use vim keybindings in copy mode
setw -g mode-keys vi

# Setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

# Update default binding of `Enter` to also use copy-pipe
unbind -t vi-copy Enter
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"

# Bind ']' to use pbpaste
bind ] run "reattach-to-user-namespace pbpaste | tmux load-buffer - && tmux paste-buffer"
  • edit your vim conf file
1
set clipboard=unnamed