Hacker News new | ask | show | jobs
by _y5hn 2249 days ago
Make 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).

2 comments

"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.

For 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"/>

  # For tmux 2.6+
  set -s set-clipboard external