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

Been using Tmux for around 6 months. I frequently use prefix + [ shortcut but always thought of it as "Scroll mode", never realized that its called "Copy mode" nor that one could copy text using keyboard.


I've used Tmux for around 8 years, and I've never had a pleasant copy/paste experience. This is not for lack of reading plenty of Google search results, installing different plugins, aliasing long command strings, to keyboard shortcuts. In the end, I'm still back where I started. I grab my mouse, highlight the text and pray that it's not longer than what fits on the page. I then hit Control+Shift+c, and I have the text on my clipboard. I've heard that there is a way to do this in a more vim-like fashion, but I've never actually gotten it to work. I used "Copy mode" every single day to be able to read what's in my scrollback buffer (test results, error output, etc) but using a key to start highlighting and copying contents to my clipboard? Man, that'd be awesome.


I am curious to hear about your experience. What OS and terminal emulator do you use? Do you run tmux on a remote host that you SSH into?

If your terminal emulator doesn't support copy escape codes, and you're running it on a remote server, you need to ssh with X forwarding in order to share your system clipboard.

I realized over the course of this thread that I know a weird amount about configuring tmux. I rely on this feature pretty heavily, so I've had to set up system clipboard integration on Mac and Linux across on multiple different terminal emulators. I'd be happy to help you get a config that works on your system, if you want.


I've used quite a few combinations over the last few years. These days I'm using Termite locally on Linux. In the past I've used iTerm on macOS/OSX.

To be very clear here, I can copy text from pane to pane. (using control+] to paste)

Judging by some recently commented lines in my tmux.conf. I've tried: # bind C-y run "tmux save-buffer - | xclip -selection c"\; display-message "Buffer copied to clipboard" # bind y "xsel -i --clipboard" # bind-key -T copy-mode-vi y send-keys -X copy-pipe "xclip"


The last one looks pretty close to working, but I don't know if xclip works with no arguments. This is what I use:

  bind-key -T copy-mode-vi y send-keys -X copy-pipe "xclip -i -selection clipboard"
That should just work if you're running tmux locally, or if you're connected to a remote session with X forwarding.


I'll definitely give it a shot. Although I didn't reply to this thread expecting "tech-support", it certainly is appreciated when fellow tech folks are willing to share what they've learned. So, thank you.




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

Search: