Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
136 views
in Technique[技术] by (71.8m points)

Clipboard failure in tmux + vim after upgrading to MacOS Sierra

Yesterday, I upgraded to MacOS Sierra and it broke my clipboard functionality in my tmux + neovim setup.

Here is the behavior:

  • I can use the standard ctrl+c, ctrl+p to copy/paste between system <-> vim
  • I can yank/paste between two VIM instances when NOT in a tmux session
  • I cannot yank/paste between two VIM instances when in a tmux session

Whenever I use the clipboard in vim within a tmux session, I get the following vim error:

clipboard: error:

My .vimrc is huge, but here's what I think might be relevant:

set clipboard=unnamed

In my .tmux.conf (also truncated for brevity):

set -g prefix `                                   # use tilde key as prefix
bind ` send-key `                                 # insert tilde by pressing twice

set -g history-limit 100000                       # set buffer size
set -s escape-time 0                              # fix escape key in vim
set -g allow-rename off                           # keep window names static
set -g default-terminal "screen-256color"         # set the TERM to 256 colors
set -g base-index 1                               # start window count at 1
set -g pane-base-index 1                          # start pane count at 1
set -g default-shell $SHELL                       # use zsh as shell

EDIT: This appears to be related to the bug reported here:

https://github.com/tmux/tmux/issues/543

https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard/issues/53

question from:https://stackoverflow.com/questions/39645253/clipboard-failure-in-tmux-vim-after-upgrading-to-macos-sierra

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This seem to be a regression on macOS Sierra. A solution that worked for me has been mentioned by Josh McGinnis https://github.com/tmux/tmux/issues/543:

brew install reattach-to-user-namespace

Ensure the following is set in .tmux.conf:

set -g default-shell $SHELL 
set -g default-command "reattach-to-user-namespace -l ${SHELL}"

In .vimrc or ~/.config/nvim/init.vim (for Neovim):

set clipboard=unnamed

Now all is well and I can copy/paste between system <-> vim sessions using vim keybindings and/or system ctrl+c / ctrl+p.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...