升级到MacOS Sierra后,tmux + vim中的剪贴板失败

昨天,我升级到MacOS Sierra,它在我的tmux + neovim设置中打破了我的剪贴板function。

这是行为:

  • 我可以用标准的ctrl + c,ctrl + p在system < – > vim之间复制/粘贴
  • 当不在tmux会话中时,我可以在两个VIM实例之间插入/粘贴
  • 在一个tmux会话中,我不能在两个VIM实例之间插入/粘贴

每当我在tmux会话中使用vim中的剪贴板时,出现以下vim错误:

clipboard: error: 

我的.vimrc是巨大的,但这是我认为可能是相关的:

 set clipboard=unnamed 

在我的.tmux.conf (为简洁起见也被截断):

 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 

编辑 :这似乎与这里报告的错误有关:

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

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

这似乎是macOS Sierra的一次倒退。 Josh McGinnis提到了一个适用于我的解决schemehttps://github.com/tmux/tmux/issues/543 :

brew install reattach-to-user-namespace

确保在.tmux.conf中设置以下内容:

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

在.vimrc或〜/ .config / nvim / init.vim中(对于Neovim):

 set clipboard=unnamed 

现在一切正常,我可以使用vim keybindings和/或系统ctrl + c / ctrl + p复制/粘贴system < – > vim会话。

升级brew + vim + tmux修复了这个问题:

 brew update brew upgrade vim brew upgrade tmux 

笔记:

  • 我不使用Neovim,但希望这将有助于无论如何
  • 这可能需要一段时间,取决于你的机器有多慢
  • 当我做了这个brew升级ruby给我,它抱怨说,它不会覆盖现有的符号链接,所以我不得不手动运行: brew link --overwrite ruby
  • Tmux在升级后抱怨以下设置。 我刚刚评论过它: # set-option -g status-utf8 on
  • 我有一个关于需要新的xcode工具的警告,所以我运行了下面的命令并接受了GUI提示符: xcode-select --install (事后看来,这可能会导致我的react-native安装:/。Buyer beware)
  • 当第一次运行brew update brew时,抱怨说它没有对/usr/local写入权限,所以我让自己成为/usr/local的所有者非RECURSIVE 。 在更新brew后告诉我,我可以改变主人回到root:wheel

升级到Sierra后我也看到了一样的情况。 在我的情况下,它源于安装了YankRing插件。

将以下内容添加到我的.vimrc中为我修复:

 "------------------------------------------------------------- " Fix for YankRing bug "------------------------------------------------------------- let g:yankring_clipboard_monitor=0