5 ms·
My biggest problem with "mouseless tmux" was copy-paste. How do you deal with that?
by cozos 6y ago
My biggest problem with "mouseless tmux" was copy-paste. How do you deal with that?
- lpilot 6y agoI haven't got my config to hand, but essentially I've binded leader-y and leader-p to copy and paste respectively both using the system clipboard. Since doing that tmux has been so much more useful to me.
- kondu 6y agoI've always wanted something like that, can you please share your config?
- jonfw 6y agoThis is the section of my config that sets up using the clipboard for tmux buffers. It won't work as is unless you're using both fish shell and Mac, but this should at least give you some good keywords to google and find documentation on how to do it for your system #makes clipboard work set-option -g default-command "reattach-to-user-namespace -l fish" bind-key -T copy-mode-vi 'v' send -X begin-selection bind-key -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy"
- Tsiklon 6y agoIf you’re using Mojave or later you don’t need `reattach-to-user-namespace` anymore :)
- ser0 6y agoI use tmux copycat paired with yank, which makes reverse searching and copy paste much easier. https://github.com/tmux-plugins/tmux-copycat https://github.com/tmux-plugins/tmux-copycat The other change is to use vi keys for highlight mode: # set highlight mode keys setw -g mode-keys vi bind Escape copy-mode
- tetris11 6y agoC-b [ goes into copy mode,then you can traverse the screen with arrows. C-Space marks a region, move arrows to select text, and M-w to copy to clipboard. q to escape copy mode
- stereolambda 6y agoI'm used to selecting only with Space, and confirming with Enter. C-b ] pastes. This seems to be to the tmux's own clipboard. When you want to copy externally many lines, you can use C-b Z to zoom or use a lame workaround with text files opened in gedit or something. (It's a marginal use case in my experience, so I didn't bother to optimize.)
- mjbrownie 6y agoA typical scrollback cut and paste workflow for me is via this <ctrl-b>P mapping. I'm lazy I just grab everything. bind-key P command-prompt -p 'save history to filename:' -I '~/tmux.history' 'capture-pane -S -32768 ; save-buffer %1 ; delete-buffer' then it's all in a file you can work with in an editor of your choice
- nmarriott 6y agoYou should be able to replace the capturep/saveb/deleteb dance with 'run "tmux capture-pane -p -S- -E- >%1"'
- loopz 6y agoMake your own cheatsheet for bindings you need. This way you learn faster and optimize for your own needs. Tmux is exceptional mouseless, though personally I prefer combining with mouse. With xclip, mouse and copy/paste can work over SSH-forwarded X-sessions with C-y and Enter from copy-mode-vi so: # For older versions of tmux: #setw -g mode-mouse on #set -g mouse-resize-pane on #set -g mouse-select-pane on #set -g mouse-select-window on # For newer versions of tmux: set -g mouse on bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; #send-keys -M'" bind -n WheelDownPane select-pane -t= \; send-keys -M set -g set-clipboard on # With xclip bind-key -n C-y run "tmux show-buffer | xclip -selection clipboard -i >/dev/null" #bind-key -n C-y run-shell "tmux save-buffer - | xclip -i -selection clipboard >/dev/null" # For tmux 2.4+ bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'xclip -selection clipboard -i' For Windows vcxsrv is the simplest and most fool-proof X-Windows server. Anything else on Windows may result in pain. My preference is to reduce visual clutter in tmux by tweaking config and mostly just follow built-in bindings so workflow mostly works on standard tmux as well. When clipboard fails between environments, sometimes multiple copy-ing, and then pasting into a text-editor helps (not a tmux issue, but clipboard-integrations).
- loopz 6y ago# For tmux 2.6+ set -s set-clipboard external
- tyingq 6y ago"For Windows vcxsrv is the simplest and most fool-proof X-Windows server. Anything else on Windows may result in pain." X servers on Windows are often a bigger cut/paste barrier than tmux. As you mention, vcxsrv seems to work better than other choices. Note there are some cut/paste/clipboard options you have to set.
- loopz 6y agoFor vcxsrv there is a .xlaunch file with xml-config that may enable clipboard (launches after installation). Mine is config.xlaunch: <?xml version="1.0" encoding="UTF-8"?> <XLaunch WindowMode="MultiWindow" ClientMode="NoClient" LocalClient="False" Display="0" LocalProgram="xcalc" RemoteProgram="xterm" RemotePassword="" PrivateKey="" RemoteHost="" RemoteUser="" XDMCPHost="" XDMCPBroadcast="False" XDMCPIndirect="False" Clipboard="True" ClipboardPrimary="True" ExtraParams="" Wgl="True" DisableAC="False" XDMCPTerminate="False"/>
- barrkel 6y agoI use Emacs copy & paste, or readline. I don't do a lot of copy & paste between different windows though. Paste in works adequately (terminal stuffs it into keyboard buffer) but may need a reformat if the mode has autoindent, while I zoom the window (C-b z) and turn off line numbers to copy out. If formatting is super important, I paste into a file with cat > file, and read the file into Emacs. I can do the same in reverse for a big copy out, and transfer the file. I do these things because I often use Emacs in a ssh session instead of tramp, because I'm coming from a different OS or need to use modes with sidecar executables, e.g. enh-ruby-mode.
- schasse 6y agoI had the very same problem. Especially, I could not jump to the string I wanted to copy. I wrote a tmux plugin for it https://github.com/schasse/tmux-jump https://github.com/schasse/tmux-jump Maybe it helps you too. Works great with https://github.com/tmux-plugins/tmux-yank https://github.com/tmux-plugins/tmux-yank
- 8192kjshad09- 6y agobind-key -T copy-mode-vi 'v' send -X begin-selection bind-key -T copy-mode-vi 'y' send -X copy-pipe-and- cancel 'xclip -in -selection clipboard' Works just like vim. Press v to go into visual mode, then y to yank the selection
- easytiger 6y agoIt's very similar to how it works in Emacs
- soraminazuki 6y agoYou can achieve copy-pasting that isn't very different from a typical GUI without deviating too much from the defaults. If you use a sufficiently new version of tmux [1] and a terminal that supports it [2], you can just right click and drag your mouse to select and copy text into the clipboard. All you need to do is put the line 'set mouse on' in your configuration. If your terminal doesn't support this feature, you can do something like bind -Tcopy-mode-vi MouseDragEnd1Pane copy-pipe-and-cancel "if [ \"$(uname)\" = 'Darwin' ]; then pbcopy; else xclip; fi" to achieve the same thing. It also looks like you can configure copy commands to pipe to a command of your choice with the upcoming version of tmux without having to override keybindings [3]. [1]: >= 2.4, maybe? [2]: Any terminal that supports OSC52 (e.g, iTerm2) [3]: https://github.com/tmux/tmux/commit/5aba26f2cb7aa9609a3c3d2bd38a3942b6a378b8 https://github.com/tmux/tmux/commit/5aba26f2cb7aa9609a3c3d2b...
- hujun 6y agoshameless plug: I wrote a tool to copy text from tmux on remote host to local OS, this is often needed when you ssh into remote host, and want to copy large amount of text (e.g. more than one screen) to local OS https://github.com/hujun-open/rclip https://github.com/hujun-open/rclip
- w0m 6y agoTmux runs in a terminal; use `[` and `]` for my tmux buffer; and the terminals OS Copy/Paste integration when i need to get things in/out. Reading these threads I didn't realize the heartburn they felt with tmux.
- xk3 6y agoFor copying text I just hold down shift before click-selecting. Works fine. But if you need to select a long bit of text which scrolls beyond the screen then I use scp or rsync