I can do this now by running this command capture-pane -S -3000 and using this keybind:

bind C-y run "tmux save-buffer - | clip"

Which requires me remembering to type capture-pane -S -3000 and pressing Ctrl+B, Ctrl+Y.

I would like to do it in one step like:

bind C-y capture-pane -S -3000; run "tmux save-buffer - | clip"

But it does not work.

Optimally, it would be nice if tmux asked how many lines I would like to copy from the buffer. For exemple:

bind C-y capture-pane -S -ASK_HOW_MANY_LINE_TO_INPUT; run "tmux save-buffer - | clip"

Then, if I press Ctrl+B, Ctrl+Y, I would type 3000 and press enter to get the last 3000 lines.

2 Answers 2


bind C-y run "tmux capture-pane -pS-|clip"

bind C-y command-prompt -p "How many lines?" 'run "tmux capture-pane -pS-%%%|clip"'


The correct answer would be using xclip -i instead of clip:`

bind-key C-y run "tmux capture-pane -pS-|xclip -i"

bind-key C-y command-prompt -p "How many lines?" 'run "tmux capture-pane -pS-%%%|xclip -i"'

But still not working because tmux is very bugged. After the first time I use this, tmux stop working and ignores me when I press Ctrl+B, Ctrl+Y.

You only hope will be trying to use https://github.com/tmux-plugins/tmux-yank but even that do not work if you are over an SSH connection. Therefore there is nothing you can do about this other that do not use this feature and do everything manually with:

  1. To save the your last 3000 history lines Ctrl+B e Shift+: and type: capture-pane -S -3000 to copy them to the tmux buffer.
  2. Lastly, press Ctrl+B, Shift+: and type save-buffer ~/filename.txt to save your console history to a file. You must you an absolute path because tmux does not respect your current directly and will save it anywhere.
  3. Now, you have to copy the file contents from your remote machine to your local computer. Just connect to your remote machine with Filezilla or WinSCP if you are on Windows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.