can’t select text with mouse.
problem at hand: how do i use the mouse to copy/paste text in xterm running tmux on PC? normally you should not have problems selecting text and pasting it with your mouse. everybody knows about left clicking and then dragging to select and copy the text. in order to paste you need to middle click your mouse. however there are certain options which if set will prevent this functionality. if you have set the following options
- mouse-select-pane
- mouse-select-window
you will notice that you are not able to select text at all.
the solution is to use the shift key.
hold down the shift key and then left click and drag across the target text. if you want to now paste the selected text back in to xterm, you must also hold down the shift key and then middle click in order to paste the text. this is not mentioned in the tmux man pages so i do not think this is a tmux feature. guess this has something to do with xterm, but i m not sure.
xterm version 278-1
tmux version 1.6-2
archlinux PC
guly in the comments informs me that iterm users on macosx need to use the option key. bruceedge pointed out that if the target text area resides in a pane of a split window then trying to copy with this method will also copy stuff from adjacent panes. to counter this problem one hack is to use the zoom pane functionality. say you want select text from a pane that resides in a split window with other panes. with keyboard focus on the target pane, you simply hit prefix + z to maximize this pane to the entire window. copy what ever it is you want to copy and then hit prefix + z again to toggle back to the previous state.
Thanks a lot for sharing this!
thank you 🙂
Thank you!
This also works in “Gnome Terminal” and “rxvt-unicode/urxvt”.
thanks for the info 🙂
Yes, you’re right! Without holding the Shift key would make tmux handle our mouse click and select events as if we were selecting it using keyboard (after a prefix-[ ). Holding it would directly send those events to the terminal emulator.
thank you for the comment 🙂 . yeah i m not too sure if this is xterm specific
Thanks a lot! I was about to throw my computer out of the window yesterday 🙂
I wanted to add that I’m using rxvt-unicode and zsh and had the same issue
thank you
thanks works with tilda 🙂
thanks for your like and comment 🙂
thank you
thank you too 🙂
Very helpful… Thank you very much.
thank u too 🙂
Thanks!
thank u too 🙂
on iTerm/macosx you need to use option key, shift doesn’t work
thanks for the info 🙂
My office mates have asked me to thank you.
Apparently, they were getting tired of my cursing… (no windows in this office).
For reference: Linux+KDE, konsole 2.9.5 -> ssh -> tmux 1.7 here, and bash everywhere.
TMux options: mode-mouse=copy-mode, mouse-select-window=on .
ha ha 🙂
they are welcome! thanks for the funny comment 🙂
Thank you!
you are welcome and thanks for the comment 🙂
What I love about this “solution” is that it is simple. I was going to play with key bindings after looking at other blogs, etc. You saved me though! Cannot beat simplicity.
Thanks!
An Archer
Many thanks! Just paying it forward and doing my duty in my limited capacity :). thanks.
Thank you soo much!!! I learned something useful today!
you are welcome. thanks for leaving a nice comment 🙂
thanks for the tip! not being able to select text with a mouse when usign tmux has been bugging me for ages – great work for taking the time to post this.
thanks mate!
Hey, thank you very much for the tip.
I’m quite new to tmux, but given good tips like yours, I almost have everything I need in my simple config :).
you are welcome mate 🙂
This works fine when you have a single column in a window, but once you split your terminal into multiple columns, the text selection spans both columns, which is never going to be what you want.
indeed you are right. thanks for pointing that out to me. i never ran in to that situation. however i can pass on a dirty hack to get around this problem.
in tmux version 1.8 one can zoom in on the pane and then unzoom using the prefix + z key chord.
so if you want to copy stuff off of a pane simply hit your prefix key (Ctrl-b) and then hit z.
this will maximize this pane. now copy your stuff and hit Ctrl-b z again.
hope that helps and thanks for the comment 🙂
Thanks!It was really helpful in my environment(mac OS10.7,iterm2,zsh)
thank you for the comment 🙂
Great solution.. After looking through soo many websites and still not being able to do it.. Kudos!
thank you for the comment 🙂
Thanks a lot. You just saved my MacBook from being thrown out of the window.
thanks for comment 🙂
Thanks for sharing this subtle info. Works for me.
You are welcome 🙂 and thanks for your comment.
Thanks 🙂 very helpful
welcome and thanks to you too for the comment 🙂
Another previously frustrated tmux user who is very thankful to have found this post. Thanks!
thanks man 🙂
This was posted on April 18, 2012 and I find it today! Need to improve my googling skills :). Freedom at last . Thanks dude.
Thnx, worked fine on Fedora with the regular gnome-terminal.
welcome and thanks for comment 🙂
Thanks man!
you are welcome 🙂 and thanks for commenting.
Thanks! It solved my problem.
You are welcome 🙂
Yeahh. It`s Great.
Thanks for comment of “Shift + Mouse selection”
thanks for your comment 🙂
ya thank you i was wanting to know this i was searching for hours on my computer ya made my day 🙂
glad to be of help 🙂 thanks for the comment
After much experimenting I settled on a mouse mode toggle so that I could have the “normal” select/paste behavior, or the mouse-mode variant as sometimes I really wanted select/paste to work normally.
I copied this from a .conf I stumbled onto, so if this is yours, please take credit.
This makes it very easy to toggle back and forth.
# Mouse mode
set -g mode-mouse on
set -g mouse-resize-pane on
set -g mouse-select-pane on
set -g mouse-select-window on
# Toggle mouse on
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’
# Toggle mouse off
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’
this is cool 🙂 thanks
First I want to thank the author and the commenter. However trying this out I had no success. Tmux was telling me that the syntax was wrong. Some commands have been made obsolete.
With the help of this site: https://wiki.archlinux.org/index.php/tmux I found how to do this and which works with version 2.2 of tmux.
# Mouse mode
set-option -g mouse on
# Toggle mouse on
bind-key m set-option -g mouse on \; display ‘Mouse: ON’
# Toggle mouse off
bind-key M set-option -g mouse off \; display ‘Mouse: OFF’
This is great… I thought only iTerm2 has this feature built into their terminal emulator before, but now it also works on my Linux box!
thanks for the comment 🙂
You sir are a life saver.
thanks. glad to be of help 🙂
Awesome!! Thanks 🙂
thanks 🙂
OMG THANK YOU I WAS GETTING CRAZY WITH THAT COPY PASTE SHIT THANK YOU YOU ARE MY SAVIOR OMG CANT BELIEVE IT OMG
so to sum up : I use option + the mouse to select the text in iterm. i then right click and a popup menu appears from which I select copy. if I have select in iterm options select to clipboard i dont need to do this second step.
Awesome and straight to the point. Danke.
Welcome 🙂
Thx for the share! I started to become crazy… You saved my day!
glad! thanks for your comment!
Cheers man 🙂
This has been driving me crazy since I started using tmux a while ago but it’s easy when you know how aint it?
thanks 🙂
All these years later, thank you for this! I swear this was driving me crazy.
thanks for taking the time to comment 🙂
‘fn’ key is working for me instead of shift or option on Mac. No idea why
thanks for that info … that will help mac users.
What you wrote in 2012 is still a very valid answer in 2018 on Ubuntu 18.04 ! You rock man, you rock. You have probably saved me hours (y)
Thanks for your comment and also for pointing out that it has been so long since I did this … hadn’t quite thought about it that way 🙂
thanks a lot!
thanks for taking the time to comment 🙂
[…] Check also: https://awhan.wordpress.com/2012/04/18/tmux-copy-paste-with-mouse/ […]
This really saved me. The copy paste buffers were the only thing that was stopping me from using tmux. Can confirm it still words in Fedora 35.
thanks!