8

tmux configuration, mouse copy & paste added

 8 months ago
source link: https://gist.github.com/rodricels/7951c3bd505d343b07309b76188af9b3
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

tmux configuration, mouse copy & paste added · GitHub

Instantly share code, notes, and snippets.

Last active January 5, 2024 03:41
  • Star 58 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
tmux configuration, mouse copy & paste added

Thanks for sharing this. I borrowed lines 33-34 from you and changed them to:

unbind-key MouseDown2Pane
bind-key -n MouseDown2Pane run " \
  X=$(xclip -o -sel clipboard); \
  tmux set-buffer \"$X\"; \
  tmux paste-buffer -p; \
  tmux display-message 'pasted!' \
"

I was finding that when I pasted something that ended in a semicolon, the pasted content would be missing the semicolon. Above is preserving the semicolon for me.

Thanks for this, finally mouse middle-click without shift works!

It took me long time to find this… But at least that works!!!

Many thanks indeed.

Copy and paste with mouse worked like a charm! Thanks for sharing.

Hey @elijahgagne,

I could not get your improvement to work. When I copied something that ended in a semicolon, it would still eat the semicolon.

But thanks for the hint, who knows when this would have hit me ;)

While playing around, I also noticed, that when pasting something that starts with a minus (like --option) then it would paste the previous thing, whatever it was.

This led to the following solution:

bind-key -n MouseDown2Pane run "tmux set-buffer -- \"$(xclip -o -sel primary);\"; tmux paste-buffer -p"
                                                ^^                           ^                      ^^
                                                [1]                          [2]                    [3]

[1]: Stop parsing options. This prevents text starting with "-" to be interpreted as options.
[2]: Always insert a semicolon. The last semicolon is always cut away, so just add a dummy.
[3]: Paste bracket control codes. Allows for example pasting in vim normal mode.

@x3rAx I agree my solution did not solve the semicolon issue. It always hits me pasting SQL statements in sqlplus. Thanks for sharing your update!

Thanks for sharing this. I borrowed lines 33-34 from you and changed them to:

unbind-key MouseDown2Pane
bind-key -n MouseDown2Pane run " \
  X=$(xclip -o -sel clipboard); \
  tmux set-buffer \"$X\"; \
  tmux paste-buffer -p; \
  tmux display-message 'pasted!' \
"

I was finding that when I pasted something that ended in a semicolon, the pasted content would be missing the semicolon. Above is preserving the semicolon for me.

It works for me on Ubuntu 20.04, thanks!

thanks for sharing, finally found a way to restore right click to paste with mouse mode on with tmux version >2.1

# paste from right click
unbind-key MouseDown3Pane
bind-key -n MouseDown3Pane run " \
  X=$(xclip -o -sel clipboard); \
  tmux set-buffer \"$X\"; \
  tmux paste-buffer -p; \
  tmux display-message 'pasted!' \
"

PS: but I still can only make it paste from tmux's copy, not from other windows ( I'm using windows's chrome secure shell for ssh )

tried this too, same result with above

bind-key -n MouseDown3Pane run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"

tyvm! i'm probably odd, but prefer "unified clipboard" (whether ctrl-* or mouse, do the same) so also found it useful that xclip lets you specify multiple select args...

xclip -se c -se p -i -r

Thank you for sharing this! Exactly solved my clipboard problems

thank you for sharing!

In centos8 stream pre install xclip , this config work well , thanks a lot~!

thanks for sharing your configs

thanks. this is the one.

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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK