Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

For me, the killer feature of tmux is actually the mouse support (e.g. clickable window names, pane selection, scrolling, copy/paste), which works even over ssh.


Yes, but it's a shame that tmux is not a good "x11 citizen". If you select some text inside tmux, you cannot middle-click on another window to copy it. Likewise, if you select some text on a non-tmux window, you can copy it everywhere, except on your tmux session. For me this means that the mouse support is severely broken, and I actually prefer to use "tmux set mouse off", by which all goodies are lost, but at least I can copy-paste like a human being.


Yeah. It's not completely tmux's fault -- it's doing what it can, in a terminal emulator -- but it could be smarter. You can make it behave the way it should with a couple lines in ~/.tmux.conf:

  # copy on select
  bind-key -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-no-clear 'xclip -i -selection primary'

  # paste on middle click
  bind-key -n MouseDown2Pane { select-pane -t=; run 'tmux set-buffer "$(xclip -o -selection primary)"'; paste-buffer }
(s/xclip/xsel, depending on your system.)


wow, many thanks! This is a neat hack. I wonder why this very natural behaviour is not the default.

Your solution is almost perfect. The "paste" code works as expected. But the "copy" code, apart from copying the selection into the clipboard, leaves the tmux pane in an odd state (copy mode) from which you have to exit manually. Would it be possible to bind the command to something that quits copy mode afterwards?


Yep! Use copy-pipe-and-cancel instead of copy-pipe-no-clear.

I don't think tmux has any, like, OS-aware anything. It can copy to the system clipboard, but only by asking your terminal emulator to copy. To work the way you expect, tmux would need to know to use xclip on Linux and pbcopy/pbpaste on macOS or whatever. Which would be pretty nice! That would be a great, easy feature that would cover ~99% of users. But it seems like it deliberately doesn't want to (?). I'm speculating there.


Thank you very much, you made my day with that!


If you hold shift, you can bypass tmux and copy/paste at the terminal emulator level.


Yes, that's what I've been doing for years, and I hate it (to the point of disabling mouse support). It is extremely annoying to have to press SHIFT for normal operations that work out of the box in every other program.

Fortunately, thanks to ianthehenry's solution on this thread, you can do the same thing without pressing shift!


And Ctrl-Shift for block selection (in some terminal emulators).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: