2

For my current project, most work happens in tmux on a remote system. Sometimes, I would like to copy text from the remote system to my local machine (i.e. for sending email). My current workflow is

  • Enter tmux copy mode and copy text
  • Run :save-buffer ~/clipboard in tmux
  • On my local machine, I have a command aliased to ssh remote-machine 'cat ~/clipboard' | pbcopy

This is a huge pain, and I'm wondering if there's a way to run a script in copy mode. Specifically, is there a way I can bind the command :save-buffer ~/clipboard to pressing Enter in copy mode? (or maybe on buffer update?)

The machine I am ssh'ing into the remote machine from is not constant, so it's ok if I still have to run the command on my mac.

baum
  • 135

1 Answers1

2

When in copy-mode, you can use copy-pipe <command>, with a command such as cat > ~/clipboard.

In Tmux 2.5 or later, you can bind that to Enter with

bind-key -T copy-mode Enter send-keys -X copy-pipe "cat > ~/clipboard"

(or -T copy-mode-vi, depending on your mode-keys setting)

See also: copy paste functionality with xclip non functional

JigglyNaga
  • 7,886