这就是我以前在tmux中复制粘贴所做的事情(使用鼠标,键盘的工作方式不同,这不是我感兴趣的):
我升级了我的操作系统,这已经获得了一个新的tmux版本。我没有改变我的.tmux.conf
配置文件。
这就是我当前版本的tmux
,1.6
(它在最新的crunchbang linux中预先打包)所做的事情:
[0/24]
,可能与粘贴了多少个字符有关),这对我来说意义不大,我不需要/想要(编辑:似乎copy-mode
在这里自动输入)对于我每天做几十次的事情来说,这太麻烦了。如何让旧机制再次运作?
要恢复默认的复制/粘贴配置,您需要(至少暂时)关闭tmux中的鼠标支持:
prefix : set -g mouse off
其中prefix
是tmux访问键(默认情况下为Ctrl + B,除非您重新映射它)。 :启动命令模式,set -g
全局设置参数。
关闭鼠标模式后,操作系统提供的标准复制/粘贴功能将按预期工作。
您可能想要做的其他事情是“最大化”当前窗格,这样您就可以轻松复制多行。
如果您正在使用旧版(2.1之前版本)的tmux,则需要使用以下内容:
prefix : set -g mode-mouse off
有更多的细节和一些方便的键绑定来自动化所有这些:
http://tangledhelix.com/blog/2012/07/16/tmux-and-mouse-mode/
上面链接的文章的主要内容是.tmux.conf的摘录:
# disable mouse control by default - change 'off' to 'on' to enable by default.
setw -g mode-mouse off
set-option -g mouse-resize-pane off
set-option -g mouse-select-pane off
set-option -g mouse-select-window off
# toggle mouse mode to allow mouse copy/paste
# set mouse on with prefix m
bind m \
set -g mode-mouse on \;\
set -g mouse-resize-pane on \;\
set -g mouse-select-pane on \;\
set -g mouse-select-window on \;\
display 'Mouse: ON'
# set mouse off with prefix M
bind M \
set -g mode-mouse off \;\
set -g mouse-resize-pane off \;\
set -g mouse-select-pane off \;\
set -g mouse-select-window off \;\
display 'Mouse: OFF'
# zoom this pane to full screen
bind + \
new-window -d -n tmux-zoom 'clear && echo TMUX ZOOM && read' \;\
swap-pane -s tmux-zoom.0 \;\
select-window -t tmux-zoom
# restore this pane
bind - \
last-window \;\
swap-pane -s tmux-zoom.0 \;\
kill-window -t tmux-zoom
left-button
键同时按下鼠标shift
。shift
键+ middle-button
粘贴文本如果“set -g mode-mouse on”你可以做到这一点:
在Mac上,按“fn”按钮,然后选择文本并用鼠标右键单击或键盘cmd + c复制。
使用<prefix>+m
打开或关闭鼠标模式
bind m run "if [[ `tmux show-option -w | grep mode-mouse.*on` ]]; then toggle=off; else toggle=on; fi; tmux display-message \"mouse tmux: \$toggle\"; tmux set-option -w mode-mouse \$toggle &> /dev/null; for cmd in mouse-select-pane mouse-resize-pane mouse-select-window; do tmux set-option -g \$cmd \$toggle &> /dev/null; done;"
我有问题让Christian的例子为Tmux 2工作,我认为有些错别字。我得到了以下工作,并且更容易阅读并设置全局和窗口模式。某人新用户和tmux很棒!
bind m run "\
tmux show-options -g | grep -q "mouse\\s*on"; \
if [ \$? = 0 ]; \
then \
toggle=off; \
else \
toggle=on; \
fi; \
tmux display-message \"mouse is now: \$toggle\"; \
tmux set-option -w mouse \$toggle; \
tmux set-option -g mouse \$toggle; \
"
修改自here - 我在原文中使用xclip
而不是xsel
:
bind -T root MouseDown2Pane run -b "xclip -o | tmux load-buffer - && tmux paste-buffer -s ' '"
这对我在tmux 2.5-rc2
欢快地工作
对于Mac + iTerm2 + tmux(版本> 2.1)的用户:
确保在tmux config中设置了鼠标模式(只需在〜/ .tmux.conf中添加set -g mode-mouse on
)。现在,要复制窗格内的文本:
option + command
并使用鼠标光标选择要复制的文本。这就像裁剪一张照片。command + c
)。只需按常规方式粘贴即可。这是Kaixuan's answer的修改版本,与Tmux 2.1兼容。
`bind m run "if [[ `tmux show-options -w | grep mouse.*on` ]]; then toggle=off; else toggle=on; fi; tmux display-message \"mouse tmux: \$toggle\"; tmux set-option -w mouse \$toggle &> /dev/null;`"
所有mode-mouse
选项已合并为一个mouse
选项,show-option
必须替换为show-options
在~/.tmux.conf
:
set -g mouse off
有bind r source-file ~/.tmux.conf
也可能有用,所以你可以做ctrl-d r
重新加载配置。