tmux + vim的复制配置

做嵌入式的同学,大多在Linux环境下开发。现在也有很多同学用OSX开发。其实他们都是类Unix系统。作为一个开发者,效率很重要。有很多重复琐碎的动作,如果能提高一点效率,多次累积起来,节省的时间和精力也是可观的。在提升效率的同时,做一个很有效率,而避免琐碎重复的动作,也很有助于心情的愉悦。所以,但凡有机会,我都会给别人安利一些好用的工具,例如tmux,vim,fish啊,等等。

有人称tmux, zsh, vim是文本处理的三剑客。这三个工具用好了确实好用。我目前的开发环境使用的是fish + tmux + vim。fish的作用和zsh差不多。本文想着重介绍的是困扰我很多年的tmux + vim的剪贴板问题。

tmux下的复制

在毕业后的若干年内,我一直在Windows下,使用putty + ssh +tmux连接远端的Linux服务器做开发。好处是,tmux可以做session管理,即便putty ssh关闭,任务不会中断。只要服务器不关闭,下次打开仍然可以快速恢复工作现场。

tmux分屏模式下的文本选中

tmux中的panel在多任务的情况下非常好用。但带来的问题是,当tmux有横向分屏的时候,复制好困难。文本的选中会跨越panel边界(图截不出来,相信使用tmux的新手同学,应该都遇到过这个问题)。解决的办法是,打开tmux的鼠标模式:

set-option -g mouse on

此时,如果通过鼠标选中,就不会跨越分屏边界。怎么复制,对于新手来说,又是一个问题。

vim用:vsplit命令分屏的时候,也有同样的问题,解决方法如出一辙,使能鼠标模式,set mouse=a。

tmux复制模式下的复制

tmux的所有操作都是通过bind-key实现的。本身有一套默认的bind-key table,当然也可以自定义,tmux插件也可以帮你定义。所以有什么不清楚的,可以直接自行查bind-key table。方法是:

  • 通过ctrl + [:进入tmux命令模式
  • 执行list-keys命令就可以了

这里需要注意的是较新的tmux 中的bind-key table较老版本的完全不同。例如笔者当前使用的最新release版tmux2.8,而Ubuntu 16.04 LTS版本源中自带的是tmux 2.1。据说tmux中间进行过重构,导致很多功能其实并不兼容老版本。所以推荐使用新版本。

Ubuntu 16.04 LTS版本的源中自带的tmux是2.1的。这会导致很多功能没法使用

# tmux 2.8 list-keys
bind-key    -T copy-mode    C-Space           send-keys -X begin-selection
bind-key    -T copy-mode    C-a               send-keys -X start-of-line
bind-key    -T copy-mode    C-b               send-keys -X cursor-left
bind-key    -T copy-mode    C-c               send-keys -X cancel
bind-key    -T copy-mode    C-e               send-keys -X end-of-line
bind-key    -T copy-mode    C-f               send-keys -X cursor-right
bind-key    -T copy-mode    C-g               send-keys -X clear-selection
bind-key    -T copy-mode    C-k               send-keys -X copy-end-of-line
bind-key    -T copy-mode    C-n               send-keys -X cursor-down
bind-key    -T copy-mode    C-p               send-keys -X cursor-up

# tmux 2.1 list-keys
bind-key        C-b send-prefix                                                     
bind-key        C-o rotate-window
bind-key        C-z suspend-client
bind-key      Space next-layout
bind-key          ! break-pane
bind-key          " split-window
bind-key          # list-buffers
bind-key          $ command-prompt -I #S "rename-session '%%'"
bind-key          % split-window -h
bind-key          & confirm-before -p "kill-window #W? (y/n)" kill-window

是不是很不一样?请自行忽略2.1版本。

2.8中的每一行其实运行的是一个bind-key命令,具体参数可以参考tmux man page

  • -T: 指定表格
  • -r: 指定该按键可以repeat。例如调整panel大小,你不想每放大缩小一次都要按prefix吧,那会抓狂的。

copy-mode就是一个具体table,在你按下ctrl + [进入复制模式时生效。同理还有个叫prefix的table,也就是普通模式下的按键表。

话说这么多,到底怎么复制?搜索这个表格的是否有copy-selection就可以了。所以通常Enter会被映射成send-keys -X copy-selection-and-cancel。也就是按下Enter,选中的文字会被复制到tmux剪贴板

tmux下复制到Windows剪贴板

这个才是本篇想说的话题。因为我花了好些年才找到答案。所以可见经验的传承是多么重要。下面先说怎么做,再说为什么。

如何做?

首先单纯靠putty是没办法的,因为putty只是单纯的terminal emulator。而Linux的剪贴板管理是需要X-Window支持的。所以你需要的是一个完整的X11 forwarding的环境。X11 forwarding有很多途径可以做到,可以自行google,笔者选择了一个turn key solution,就是安装MobaXTerm。默认的配置就已经使能X11 server和X11 forwarding了。

接下来,要做的就是:

  • 确定你的Linux系统里有X11界面,如果没有请自行google安装
  • 确定你的Linux系统里有xclip, xsel或xclipboard三者之一
  • 如果你的DISPLAY变量在tmux下不正常,可以在.tmux.conf下添加
set -g update-environment "\
    DISPLAY \
    "
  • bind-key -T copy-mode y send-keys -X copy-pipe-and-cancel "xsel -i --clipboard"

最后一步更优雅的解决方法是安装tmux-yank插件。

为什么要这么做?

Linux的桌面系统管理了一个剪贴板,这个剪贴板依赖于X Window系统,由前述的几种app管理,类似于Windows下的clip.exe。当在Windows下用ssh连接Linux的时候,如果未设置X11 forwarding,则在Windows下是无法使用到xsel,xclip或者xclipboard的,所以无法访问Linux的剪贴板内容。如果设置好了X11 forwarding,则在Windows下就能访问Linux剪贴板。

tmux本身也管理了一个剪贴板,称为buffer。tmux的命令copy-selection, paste-buffer, list-buffers就是针对tmux自身的剪贴板的操作。tmux原生支持,通过空格选中,Enter复制,ctrl + ] 粘贴。

如果想tmux下将终端显示内容复制到Windows剪贴板要做的就是把tmux剪贴板发送到X11的剪贴板中。tmux-yank插件做的就是这件事。当然你也可以通过在copy-mode-vi表格里绑定任何按键来做这件事情。

vim复制到Windows剪贴板

没有运行在tmux下的vim或是gvim要复制到Windows剪贴板,或者说是系统剪贴板,依赖的是vim的寄存器操作。可以自行google。系统剪贴板对应的vim寄存器是"+。所以在vim下如果想复制到系统剪贴板,你可以用"+y来取代平时常用的y。例如:

  • "+yy:复制当前行到系统剪贴板
  • "+yw:复制当前的单词到系统剪贴板

如果vim运行在tmux下,因为tmux自带的剪贴板就有点麻烦了。这时候有一个插件就比较有用了——vim-tmux-clipboard。他依赖于另一个vim插件vim-tmux-focus-events。装好这两个插件,在.tmux.conf中添加

set -g focus-events on

大功告成。现在在vim下,直接使用yank快捷键,不用指定寄存器,就可以直接复制内容到tmux剪贴板,同时因为tmux-yank的存在,文本也会被复制到系统剪贴板。

%E5%81%9A%E5%B5%8C%E5%85%A5%E5%BC%8F%E7%9A%84%E5%90%8C%E5%AD%A6%EF%BC%8C%E5%A4%A7%E5%A4%9A%E5%9C%A8Linux%E7%8E%AF%E5%A2%83%E4%B8%8B%E5%BC%80%E5%8F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E6%9C%89%E6%9C%BA%E4%BC%9A%EF%BC%8C%E6%88%91%E9%83%BD%E4%BC%9A%E7%BB%99%E5%88%AB%E4%BA%BA%E5%AE%89%E5%88%A9%E4%B8%80%E4%BA%9B%E5%A5%BD%E7%94%A8%E7%9A%84%E5%B7%A5%E5%85%B7%EF%BC%8C%E4%BE%8B%E5%A6%82tmux%EF%BC%8Cvim%EF%BC%8Cfish%E5%95%8A%EF%BC%8C%E7%AD%89%E7%AD%89%E3%80%82%0A%0A%E6%9C%89%E4%BA%BA%E7%A7%B0tmux%2C%20zsh%2C%20vim%E6%98%AF%E6%96%87%E6%9C%AC%E5%A4%84%E7%90%86%E7%9A%84%E4%B8%89%E5%89%91%E5%AE%A2%E3%80%82%E8%BF%99%E4%B8%89%E4%B8%AA%E5%B7%A5%E5%85%B7%E7%94%A8%E5%A5%BD%E4%BA%86%E7%A1%AE%E5%AE%9E%E5%A5%BD%E7%94%A8%E3%80%82%E6%88%91%E7%9B%AE%E5%89%8D%E7%9A%84%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E4%BD%BF%E7%94%A8%E7%9A%84%E6%98%AFfish%20%2B%20tmux%20%2B%20vim%E3%80%82fish%E7%9A%84%E4%BD%9C%E7%94%A8%E5%92%8Czsh%E5%B7%AE%E4%B8%8D%E5%A4%9A%E3%80%82%E6%9C%AC%E6%96%87%E6%83%B3%E7%9D%80%E9%87%8D%E4%BB%8B%E7%BB%8D%E7%9A%84%E6%98%AF%E5%9B%B0%E6%89%B0%E6%88%91%E5%BE%88%E5%A4%9A%E5%B9%B4%E7%9A%84tmux%20%2B%20vim%E7%9A%84%E5%89%AA%E8%B4%B4%E6%9D%BF%E9%97%AE%E9%A2%98%E3%80%82%0A%0A%23%23%20tmux%E4%B8%8B%E7%9A%84%E5%A4%8D%E5%88%B6%0A%0A%E5%9C%A8%E6%AF%95%E4%B8%9A%E5%90%8E%E7%9A%84%E8%8B%A5%E5%B9%B2%E5%B9%B4%E5%86%85%EF%BC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84%E9%97%AE%E9%A2%98%EF%BC%8C%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95%E5%A6%82%E5%87%BA%E4%B8%80%E8%BE%99%EF%BC%8C%E4%BD%BF%E8%83%BD%E9%BC%A0%E6%A0%87%E6%A8%A1%E5%BC%8F%EF%BC%8Cset%20mouse%3Da%E3%80%82%0A%0A%23%23%23%20tmux%E5%A4%8D%E5%88%B6%E6%A8%A1%E5%BC%8F%E4%B8%8B%E7%9A%84%E5%A4%8D%E5%88%B6%0A%0Atmux%E7%9A%84%E6%89%80%E6%9C%89%E6%93%8D%E4%BD%9C%E9%83%BD%E6%98%AF%E9%80%9A%E8%BF%87bind-key%E5%AE%9E%E7%8E%B0%E7%9A%84%E3%80%82%E6%9C%AC%E8%BA%AB%E6%9C%89%E4%B8%80%E5%A5%97%E9%BB%98%E8%AE%A4%E7%9A%84bind-key%20table%EF%BC%8C%E5%BD%93%E7%84%B6%E4%B9%9F%E5%8F%AF%E4%BB%A5%E8%87%AA%E5%AE%9A%E4%B9%89%EF%BC%8Ctmux%E6%8F%92%E4%BB%B6%E4%B9%9F%E5%8F%AF%E4%BB%A5%E5%B8%AE%E4%BD%A0%E5%AE%9A%E4%B9%89%E3%80%82%E6%89%80%E4%BB%A5%E6%9C%89%E4%BB%80%E4%B9%88%E4%B8%8D%E6%B8%85%E6%A5%9A%E7%9A%84%EF%BC%8C%E5%8F%AF%E4%BB%A5%E7%9B%B4%E6%8E%A5%E8%87%AA%E8%A1%8C%E6%9F%A5bind-key%20table%E3%80%82%E6%96%B9%E6%B3%95%E6%98%AF%EF%BC%9A%0A%0A-%20%E9%80%9A%E8%BF%87%60ctrl%20%2B%20%5B%3A%60%E8%BF%9B%E5%85%A5tmux%E5%91%BD%E4%BB%A4%E6%A8%A1%E5%BC%8F%0A-%20%E6%89%A7%E8%A1%8C%60list-keys%60%E5%91%BD%E4%BB%A4%E5%B0%B1%E5%8F%AF%E4%BB%A5%E4%BA%86%0A%0A%E8%BF%99%E9%87%8C%E9%9C%80%E8%A6%81%E6%B3%A8%E6%84%8F%E7%9A%84%E6%98%AF%E8%BE%83%E6%96%B0%E7%9A%84tmux%20%E4%B8%AD%E7%9A%84bind-key%20table%E8%BE%83%E8%80%81%E7%89%88%E6%9C%AC%E7%9A%84%E5%AE%8C%E5%85%A8%E4%B8%8D%E5%90%8C%E3%80%82%E4%BE%8B%E5%A6%82%E7%AC%94%E8%80%85%E5%BD%93%E5%89%8D%E4%BD%BF%E7%94%A8%E7%9A%84%E6%9C%80%E6%96%B0release%E7%89%88tmux2.8%EF%BC%8C%E8%80%8CUbuntu%2016.04%20LTS%E7%89%88%E6%9C%AC%E6%BA%90%E4%B8%AD%E8%87%AA%E5%B8%A6%E7%9A%84%E6%98%AFtmux%202.1%E3%80%82%E6%8D%AE%E8%AF%B4tmux%E4%B8%AD%E9%97%B4%E8%BF%9B%E8%A1%8C%E8%BF%87%E9%87%8D%E6%9E%84%EF%BC%8C%E5%AF%BC%E8%87%B4%E5%BE%88%E5%A4%9A%E5%8A%9F%E8%83%BD%E5%85%B6%E5%AE%9E%E5%B9%B6%E4%B8%8D%E5%85%BC%E5%AE%B9%E8%80%81%E7%89%88%E6%9C%AC%E3%80%82%E6%89%80%E4%BB%A5%E6%8E%A8%E8%8D%90%E4%BD%BF%E7%94%A8%E6%96%B0%E7%89%88%E6%9C%AC%E3%80%82%0A%0A%3E%20Ubuntu%2016.04%20LTS%E7%89%88%E6%9C%AC%E7%9A%84%E6%BA%90%E4%B8%AD%E8%87%AA%E5%B8%A6%E7%9A%84tmux%E6%98%AF2.1%E7%9A%84%E3%80%82%E8%BF%99%E4%BC%9A%E5%AF%BC%E8%87%B4%E5%BE%88%E5%A4%9A%E5%8A%9F%E8%83%BD%E6%B2%A1%E6%B3%95%E4%BD%BF%E7%94%A8%0A%3E%0A%3E%20%60%60%60tmux%0A%3E%20%23%20tmux%202.8%20list-keys%0A%3E%20bind-key%20%20%20%20-T%20copy-mode%20%20%20%20C-Space%20%20%20%20%20%20%20%20%20%20%20send-keys%20-X%20begin-selection%0A%3E%20bind-key%20%20%20%20-T%20copy-mode%20%20%20%20C-a%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20send-keys%20-X%20start-of-line%0A%3E%20bind-key%20%20%20%20-T%20copy-mode%20%20%20%20C-b%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20send-keys%20-X%20cursor-left%0A%3E%20bind-key%20%20%20%20-T%20copy-mode%20%20%20%20C-c%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20send-keys%20-X%20cancel%0A%3E%20bind-key%20%20%20%20-T%20copy-mode%20%20%20%20C-e%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20send-keys%20-X%20end-of-line%0A%3E%20bind-key%20%20%20%20-T%20copy-mode%20%20%20%20C-f%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20send-keys%20-X%20cursor-right%0A%3E%20bind-key%20%20%20%20-T%20copy-mode%20%20%20%20C-g%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20send-keys%20-X%20clear-selection%0A%3E%20bind-key%20%20%20%20-T%20copy-mode%20%20%20%20C-k%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20send-keys%20-X%20copy-end-of-line%0A%3E%20bind-key%20%20%20%20-T%20copy-mode%20%20%20%20C-n%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20send-keys%20-X%20cursor-down%0A%3E%20bind-key%20%20%20%20-T%20copy-mode%20%20%20%20C-p%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20send-keys%20-X%20cursor-up%0A%3E%20%0A%3E%20%23%20tmux%202.1%20list-keys%0A%3E%20bind-key%20%20%20%20%20%20%20%20C-b%20send-prefix%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%3E%20bind-key%20%20%20%20%20%20%20%20C-o%20rotate-window%0A%3E%20bind-key%20%20%20%20%20%20%20%20C-z%20suspend-client%0A%3E%20bind-key%20%20%20%20%20%20Space%20next-layout%0A%3E%20bind-key%20%20%20%20%20%20%20%20%20%20!%20break-pane%0A%3E%20bind-key%20%20%20%20%20%20%20%20%20%20%22%20split-window%0A%3E%20bind-key%20%20%20%20%20%20%20%20%20%20%23%20list-buffers%0A%3E%20bind-key%20%20%20%20%20%20%20%20%20%20%24%20command-prompt%20-I%20%23S%20%22rename-session%20'%25%25'%22%0A%3E%20bind-key%20%20%20%20%20%20%20%20%20%20%25%20split-window%20-h%0A%3E%20bind-key%20%20%20%20%20%20%20%20%20%20%26%20confirm-before%20-p%20%22kill-window%20%23W%3F%20(y%2Fn)%22%20kill-window%0A%3E%20%60%60%60%0A%3E%0A%3E%20%E6%98%AF%E4%B8%8D%E6%98%AF%E5%BE%88%E4%B8%8D%E4%B8%80%E6%A0%B7%EF%BC%9F%E8%AF%B7%E8%87%AA%E8%A1%8C%E5%BF%BD%E7%95%A52.1%E7%89%88%E6%9C%AC%E3%80%82%0A%3E%0A%3E%202.8%E4%B8%AD%E7%9A%84%E6%AF%8F%E4%B8%80%E8%A1%8C%E5%85%B6%E5%AE%9E%E8%BF%90%E8%A1%8C%E7%9A%84%E6%98%AF%E4%B8%80%E4%B8%AAbind-key%E5%91%BD%E4%BB%A4%EF%BC%8C%E5%85%B7%E4%BD%93%E5%8F%82%E6%95%B0%E5%8F%AF%E4%BB%A5%E5%8F%82%E8%80%83%5Btmux%20man%20page%5D(http%3A%2F%2Fman.openbsd.org%2FOpenBSD-current%2Fman1%2Ftmux.1)%0A%3E%0A%3E%20-%20-T%3A%20%E6%8C%87%E5%AE%9A%E8%A1%A8%E6%A0%BC%0A%3E%20-%20-r%3A%20%E6%8C%87%E5%AE%9A%E8%AF%A5%E6%8C%89%E9%94%AE%E5%8F%AF%E4%BB%A5repeat%E3%80%82%E4%BE%8B%E5%A6%82%E8%B0%83%E6%95%B4panel%E5%A4%A7%E5%B0%8F%EF%BC%8C%E4%BD%A0%E4%B8%8D%E6%83%B3%E6%AF%8F%E6%94%BE%E5%A4%A7%E7%BC%A9%E5%B0%8F%E4%B8%80%E6%AC%A1%E9%83%BD%E8%A6%81%E6%8C%89prefix%E5%90%A7%EF%BC%8C%E9%82%A3%E4%BC%9A%E6%8A%93%E7%8B%82%E7%9A%84%E3%80%82%0A%3E%0A%3E%20copy-mode%E5%B0%B1%E6%98%AF%E4%B8%80%E4%B8%AA%E5%85%B7%E4%BD%93table%EF%BC%8C%E5%9C%A8%E4%BD%A0%E6%8C%89%E4%B8%8B%60ctrl%20%2B%20%5B%60%E8%BF%9B%E5%85%A5%E5%A4%8D%E5%88%B6%E6%A8%A1%E5%BC%8F%E6%97%B6%E7%94%9F%E6%95%88%E3%80%82%E5%90%8C%E7%90%86%E8%BF%98%E6%9C%89%E4%B8%AA%E5%8F%ABprefix%E7%9A%84table%EF%BC%8C%E4%B9%9F%E5%B0%B1%E6%98%AF%E6%99%AE%E9%80%9A%E6%A8%A1%E5%BC%8F%E4%B8%8B%E7%9A%84%E6%8C%89%E9%94%AE%E8%A1%A8%E3%80%82%0A%0A%E8%AF%9D%E8%AF%B4%E8%BF%99%E4%B9%88%E5%A4%9A%EF%BC%8C%E5%88%B0%E5%BA%95%E6%80%8E%E4%B9%88%E5%A4%8D%E5%88%B6%EF%BC%9F%E6%90%9C%E7%B4%A2%E8%BF%99%E4%B8%AA%E8%A1%A8%E6%A0%BC%E7%9A%84%E6%98%AF%E5%90%A6%E6%9C%89%60copy-selection%60%E5%B0%B1%E5%8F%AF%E4%BB%A5%E4%BA%86%E3%80%82%E6%89%80%E4%BB%A5%E9%80%9A%E5%B8%B8%60Enter%60%E4%BC%9A%E8%A2%AB%E6%98%A0%E5%B0%84%E6%88%90%60send-keys%20-X%20copy-selection-and-cancel%60%E3%80%82%E4%B9%9F%E5%B0%B1%E6%98%AF**%E6%8C%89%E4%B8%8BEnter%EF%BC%8C%E9%80%89%E4%B8%AD%E7%9A%84%E6%96%87%E5%AD%97%E4%BC%9A%E8%A2%AB%E5%A4%8D%E5%88%B6%E5%88%B0tmux%E5%89%AA%E8%B4%B4%E6%9D%BF**%E3%80%82%0A%0A%23%23%20tmux%E4%B8%8B%E5%A4%8D%E5%88%B6%E5%88%B0Windows%E5%89%AA%E8%B4%B4%E6%9D%BF%0A%0A%E8%BF%99%E4%B8%AA%E6%89%8D%E6%98%AF%E6%9C%AC%E7%AF%87%E6%83%B3%E8%AF%B4%E7%9A%84%E8%AF%9D%E9%A2%98%E3%80%82%E5%9B%A0%E4%B8%BA%E6%88%91%E8%8A%B1%E4%BA%86%E5%A5%BD%E4%BA%9B%E5%B9%B4%E6%89%8D%E6%89%BE%E5%88%B0%E7%AD%94%E6%A1%88%E3%80%82%E6%89%80%E4%BB%A5%E5%8F%AF%E8%A7%81%E7%BB%8F%E9%AA%8C%E7%9A%84%E4%BC%A0%E6%89%BF%E6%98%AF%E5%A4%9A%E4%B9%88%E9%87%8D%E8%A6%81%E3%80%82%E4%B8%8B%E9%9D%A2%E5%85%88%E8%AF%B4%E6%80%8E%E4%B9%88%E5%81%9A%EF%BC%8C%E5%86%8D%E8%AF%B4%E4%B8%BA%E4%BB%80%E4%B9%88%E3%80%82%0A%0A%23%23%23%20%E5%A6%82%E4%BD%95%E5%81%9A%EF%BC%9F%0A%0A%E9%A6%96%E5%85%88%E5%8D%95%E7%BA%AF%E9%9D%A0putty%E6%98%AF%E6%B2%A1%E5%8A%9E%E6%B3%95%E7%9A%84%EF%BC%8C%E5%9B%A0%E4%B8%BAputty%E5%8F%AA%E6%98%AF%E5%8D%95%E7%BA%AF%E7%9A%84terminal%20emulator%E3%80%82%E8%80%8CLinux%E7%9A%84%E5%89%AA%E8%B4%B4%E6%9D%BF%E7%AE%A1%E7%90%86%E6%98%AF%E9%9C%80%E8%A6%81X-Window%E6%94%AF%E6%8C%81%E7%9A%84%E3%80%82%E6%89%80%E4%BB%A5%E4%BD%A0%E9%9C%80%E8%A6%81%E7%9A%84%E6%98%AF%E4%B8%80%E4%B8%AA%E5%AE%8C%E6%95%B4%E7%9A%84X11%20forwarding%E7%9A%84%E7%8E%AF%E5%A2%83%E3%80%82X11%20forwarding%E6%9C%89%E5%BE%88%E5%A4%9A%E9%80%94%E5%BE%84%E5%8F%AF%E4%BB%A5%E5%81%9A%E5%88%B0%EF%BC%8C%E5%8F%AF%E4%BB%A5%E8%87%AA%E8%A1%8Cgoogle%EF%BC%8C%E7%AC%94%E8%80%85%E9%80%89%E6%8B%A9%E4%BA%86%E4%B8%80%E4%B8%AAturn%20key%20solution%EF%BC%8C%E5%B0%B1%E6%98%AF%E5%AE%89%E8%A3%85%5BMobaXTerm%5D(https%3A%2F%2Fmobaxterm.mobatek.net%2F)%E3%80%82%E9%BB%98%E8%AE%A4%E7%9A%84%E9%85%8D%E7%BD%AE%E5%B0%B1%E5%B7%B2%E7%BB%8F%E4%BD%BF%E8%83%BDX11%20server%E5%92%8CX11%20forwarding%E4%BA%86%E3%80%82%0A%0A%E6%8E%A5%E4%B8%8B%E6%9D%A5%EF%BC%8C%E8%A6%81%E5%81%9A%E7%9A%84%E5%B0%B1%E6%98%AF%EF%BC%9A%0A%0A-%20%E7%A1%AE%E5%AE%9A%E4%BD%A0%E7%9A%84Linux%E7%B3%BB%E7%BB%9F%E9%87%8C%E6%9C%89X11%E7%95%8C%E9%9D%A2%EF%BC%8C%E5%A6%82%E6%9E%9C%E6%B2%A1%E6%9C%89%E8%AF%B7%E8%87%AA%E8%A1%8Cgoogle%E5%AE%89%E8%A3%85%0A-%20%E7%A1%AE%E5%AE%9A%E4%BD%A0%E7%9A%84Linux%E7%B3%BB%E7%BB%9F%E9%87%8C%E6%9C%89xclip%2C%20xsel%E6%88%96xclipboard%E4%B8%89%E8%80%85%E4%B9%8B%E4%B8%80%0A-%20%E5%A6%82%E6%9E%9C%E4%BD%A0%E7%9A%84DISPLAY%E5%8F%98%E9%87%8F%E5%9C%A8tmux%E4%B8%8B%E4%B8%8D%E6%AD%A3%E5%B8%B8%EF%BC%8C%E5%8F%AF%E4%BB%A5%E5%9C%A8.tmux.conf%E4%B8%8B%E6%B7%BB%E5%8A%A0%0A%0A%60%60%60tmux%0Aset%20-g%20update-environment%20%22%5C%0A%20%20%20%20DISPLAY%20%5C%0A%20%20%20%20%22%0A%60%60%60%0A%0A-%20bind-key%20-T%20copy-mode%20y%20send-keys%20-X%20copy-pipe-and-cancel%20%22xsel%20-i%20--clipboard%22%0A%0A%E6%9C%80%E5%90%8E%E4%B8%80%E6%AD%A5%E6%9B%B4%E4%BC%98%E9%9B%85%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95%E6%98%AF%E5%AE%89%E8%A3%85%5Btmux-yank%5D(https%3A%2F%2Fgithub.com%2Ftmux-plugins%2Ftmux-yank)%E6%8F%92%E4%BB%B6%E3%80%82%0A%0A%23%23%23%20%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E8%BF%99%E4%B9%88%E5%81%9A%EF%BC%9F%0A%0ALinux%E7%9A%84%E6%A1%8C%E9%9D%A2%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86%E4%BA%86%E4%B8%80%E4%B8%AA%E5%89%AA%E8%B4%B4%E6%9D%BF%EF%BC%8C%E8%BF%99%E4%B8%AA%E5%89%AA%E8%B4%B4%E6%9D%BF%E4%BE%9D%E8%B5%96%E4%BA%8EX%20Window%E7%B3%BB%E7%BB%9F%EF%BC%8C%E7%94%B1%E5%89%8D%E8%BF%B0%E7%9A%84%E5%87%A0%E7%A7%8Dapp%E7%AE%A1%E7%90%86%EF%BC%8C%E7%B1%BB%E4%BC%BC%E4%BA%8EWindows%E4%B8%8B%E7%9A%84clip.exe%E3%80%82%E5%BD%93%E5%9C%A8Windows%E4%B8%8B%E7%94%A8ssh%E8%BF%9E%E6%8E%A5Linux%E7%9A%84%E6%97%B6%E5%80%99%EF%BC%8C%E5%A6%82%E6%9E%9C%E6%9C%AA%E8%AE%BE%E7%BD%AEX11%20forwarding%EF%BC%8C%E5%88%99%E5%9C%A8Windows%E4%B8%8B%E6%98%AF%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8%E5%88%B0xsel%EF%BC%8Cxclip%E6%88%96%E8%80%85xclipboard%E7%9A%84%EF%BC%8C%E6%89%80%E4%BB%A5%E6%97%A0%E6%B3%95%E8%AE%BF%E9%97%AELinux%E7%9A%84%E5%89%AA%E8%B4%B4%E6%9D%BF%E5%86%85%E5%AE%B9%E3%80%82%E5%A6%82%E6%9E%9C%E8%AE%BE%E7%BD%AE%E5%A5%BD%E4%BA%86X11%20forwarding%EF%BC%8C%E5%88%99%E5%9C%A8Windows%E4%B8%8B%E5%B0%B1%E8%83%BD%E8%AE%BF%E9%97%AELinux%E5%89%AA%E8%B4%B4%E6%9D%BF%E3%80%82%0A%0Atmux%E6%9C%AC%E8%BA%AB%E4%B9%9F%E7%AE%A1%E7%90%86%E4%BA%86%E4%B8%80%E4%B8%AA%E5%89%AA%E8%B4%B4%E6%9D%BF%EF%BC%8C%E7%A7%B0%E4%B8%BAbuffer%E3%80%82tmux%E7%9A%84%E5%91%BD%E4%BB%A4copy-selection%2C%20paste-buffer%2C%20list-buffers%E5%B0%B1%E6%98%AF%E9%92%88%E5%AF%B9tmux%E8%87%AA%E8%BA%AB%E7%9A%84%E5%89%AA%E8%B4%B4%E6%9D%BF%E7%9A%84%E6%93%8D%E4%BD%9C%E3%80%82tmux%E5%8E%9F%E7%94%9F%E6%94%AF%E6%8C%81%EF%BC%8C%E9%80%9A%E8%BF%87%E7%A9%BA%E6%A0%BC%E9%80%89%E4%B8%AD%EF%BC%8CEnter%E5%A4%8D%E5%88%B6%EF%BC%8Cctrl%20%2B%20%5D%20%E7%B2%98%E8%B4%B4%E3%80%82%0A%0A%E5%A6%82%E6%9E%9C%E6%83%B3tmux%E4%B8%8B%E5%B0%86%E7%BB%88%E7%AB%AF%E6%98%BE%E7%A4%BA%E5%86%85%E5%AE%B9%E5%A4%8D%E5%88%B6%E5%88%B0Windows%E5%89%AA%E8%B4%B4%E6%9D%BF%E8%A6%81%E5%81%9A%E7%9A%84%E5%B0%B1%E6%98%AF%E6%8A%8Atmux%E5%89%AA%E8%B4%B4%E6%9D%BF%E5%8F%91%E9%80%81%E5%88%B0X11%E7%9A%84%E5%89%AA%E8%B4%B4%E6%9D%BF%E4%B8%AD%E3%80%82tmux-yank%E6%8F%92%E4%BB%B6%E5%81%9A%E7%9A%84%E5%B0%B1%E6%98%AF%E8%BF%99%E4%BB%B6%E4%BA%8B%E3%80%82%E5%BD%93%E7%84%B6%E4%BD%A0%E4%B9%9F%E5%8F%AF%E4%BB%A5%E9%80%9A%E8%BF%87%E5%9C%A8copy-mode-vi%E8%A1%A8%E6%A0%BC%E9%87%8C%E7%BB%91%E5%AE%9A%E4%BB%BB%E4%BD%95%E6%8C%89%E9%94%AE%E6%9D%A5%E5%81%9A%E8%BF%99%E4%BB%B6%E4%BA%8B%E6%83%85%E3%80%82%0A%0A%23%23%20vim%E5%A4%8D%E5%88%B6%E5%88%B0Windows%E5%89%AA%E8%B4%B4%E6%9D%BF%0A%0A%E6%B2%A1%E6%9C%89%E8%BF%90%E8%A1%8C%E5%9C%A8tmux%E4%B8%8B%E7%9A%84vim%E6%88%96%E6%98%AFgvim%E8%A6%81%E5%A4%8D%E5%88%B6%E5%88%B0Windows%E5%89%AA%E8%B4%B4%E6%9D%BF%EF%BC%8C%E6%88%96%E8%80%85%E8%AF%B4%E6%98%AF%E7%B3%BB%E7%BB%9F%E5%89%AA%E8%B4%B4%E6%9D%BF%EF%BC%8C%E4%BE%9D%E8%B5%96%E7%9A%84%E6%98%AFvim%E7%9A%84%E5%AF%84%E5%AD%98%E5%99%A8%E6%93%8D%E4%BD%9C%E3%80%82%E5%8F%AF%E4%BB%A5%E8%87%AA%E8%A1%8Cgoogle%E3%80%82%E7%B3%BB%E7%BB%9F%E5%89%AA%E8%B4%B4%E6%9D%BF%E5%AF%B9%E5%BA%94%E7%9A%84vim%E5%AF%84%E5%A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F%92%E4%BB%B6%5Bvim-tmux-focus-events%5D(https%3A%2F%2Fgithub.com%2Ftmux-plugins%2Fvim-tmux-focus-events)%E3%80%82%E8%A3%85%E5%A5%BD%E8%BF%99%E4%B8%A4%E4%B8%AA%E6%8F%92%E4%BB%B6%EF%BC%8C%E5%9C%A8.tmux.conf%E4%B8%AD%E6%B7%BB%E5%8A%A0%0A%0A%60%60%60tmux%0Aset%20-g%20focus-events%20on%0A%60%60%60%0A%0A%E5%A4%A7%E5%8A%9F%E5%91%8A%E6%88%90%E3%80%82%E7%8E%B0%E5%9C%A8%E5%9C%A8vim%E4%B8%8B%EF%BC%8C%E7%9B%B4%E6%8E%A5%E4%BD%BF%E7%94%A8yank%E5%BF%AB%E6%8D%B7%E9%94%AE%EF%BC%8C%E4%B8%8D%E7%94%A8%E6%8C%87%E5%AE%9A%E5%AF%84%E5%AD%98%E5%99%A8%EF%BC%8C%E5%B0%B1%E5%8F%AF%E4%BB%A5%E7%9B%B4%E6%8E%A5%E5%A4%8D%E5%88%B6%E5%86%85%E5%AE%B9%E5%88%B0tmux%E5%89%AA%E8%B4%B4%E6%9D%BF%EF%BC%8C%E5%90%8C%E6%97%B6%E5%9B%A0%E4%B8%BAtmux-yank%E7%9A%84%E5%AD%98%E5%9C%A8%EF%BC%8C%E6%96%87%E6%9C%AC%E4%B9%9F%E4%BC%9A%E8%A2%AB%E5%A4%8D%E5%88%B6%E5%88%B0%E7%B3%BB%E7%BB%9F%E5%89%AA%E8%B4%B4%E6%9D%BF%E3%80%82