升级到MacOS Sierra后,tmux + vim中的剪贴板失败 [英] Clipboard failure in tmux + vim after upgrading to MacOS Sierra

查看:126
本文介绍了升级到MacOS Sierra后,tmux + vim中的剪贴板失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天,我升级到了MacOS Sierra,它破坏了我在tmux + neovim设置中的剪贴板功能.

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

这是行为:

  • 我可以使用标准ctrl + c,ctrl + p在系统<-> vim之间复制/粘贴
  • 当不在tmux会话中时,我可以在两个VIM实例之间拉动/粘贴
  • 在tmux会话中,我无法在两个VIM实例之间拉动/粘贴

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

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

clipboard: error:

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

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

set clipboard=unnamed

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

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

推荐答案

这似乎是macOS Sierra上的回归. Josh McGinnis (https://github.com/tmux/tmux/issues/543 :

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

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

Ensure the following is set in .tmux.conf:

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

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

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

set clipboard=unnamed

现在一切都很好,我可以使用vim键绑定和/或系统ctrl + c/ctrl + p在系统<-> vim会话之间复制/粘贴.

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

这篇关于升级到MacOS Sierra后,tmux + vim中的剪贴板失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆