Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sumonst21/cb5c4a57bb7552d9a4cc23b8dafa2961 to your computer and use it in GitHub Desktop.
Save sumonst21/cb5c4a57bb7552d9a4cc23b8dafa2961 to your computer and use it in GitHub Desktop.
tmux copy-mode to file (Termius on Windows, Debian server)

tmux copy-mode to file (Termius on Windows, Debian server)

If you can’t visually highlight with plain Space (Termius sends Ctrl+Space), and want to save tmux copy-mode selection to a file, do this:


Setup inside tmux:

  1. Press Ctrl+b then :
  2. Paste these lines one by one, pressing Enter after each:
set -g mode-keys vi
bind -T copy-mode-vi C-Space send -X begin-selection
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "tee /tmp/tmux-out.txt >/dev/null"

How to use:

  • Ctrl+b then [
  • Move to start of text to copy
  • Press Ctrl+Space to begin selection
  • Move cursor to end of text
  • Press y (no Enter) and wait till cursor returns to normal (time varies based on selection size), copy-mode will exit automatically
  • The copied text is saved to /tmp/tmux-out.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment