Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Stop tmux-yank from Scrolling Down After Copying Text with Your Mouse

stop-tmux-yank-from-scrolling-down-after-copying-text-with-your-mouse.jpg

By default when you copy text with the mouse yank will scroll you back to the bottom of your buffer. Here's how to disable that behavior.

Quick Jump:

I’m sure you’ve experienced this. You’re using the tmux-yank plugin, scroll up in your buffer and copy text with your mouse. After you release your left mouse button you get auto-scrolled down to the bottom of your buffer.

I normally like being in control of when things on my screen change. Oftentimes after I copy text I still want my scroll position to be where the selected text is. This is especially true when recording videos where I want to talk about the thing that was just copied and I’m not ready to paste it yet.

In your tmux config you can set set -g @yank_action "copy-pipe" instead of using the default "copy-pipe-cancel" action. After restarting your tmux server you’ll no longer get auto-scrolled. When you want to scroll down manually you can hit q.

I’ve commit this change to my dotfiles and the video below shows both options in action.

# Demo Video

Timestamps

  • 0:08 – Scrolling to the bottom by default
  • 0:49 – Configuring tmux-yank to prevent auto-scrolling
  • 1:19 – Showing the new behavior

Are you going to configure tmux this way? Let me know below.

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per year (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments