Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to enable "copy-selection-no-clear" option? #721

Closed
waldauf opened this issue Feb 26, 2024 · 5 comments
Closed

Question: How to enable "copy-selection-no-clear" option? #721

waldauf opened this issue Feb 26, 2024 · 5 comments

Comments

@waldauf
Copy link

waldauf commented Feb 26, 2024

Hello,

first, thank You for Your great config which I've been using for years.

I would like to have the possibility to copy the text in copy-mode (via keyboard or mouse) and after copying to register/clipboard I stay in copy-mode. I found out there is an option for that called copy-selection-no-clear. But I am not sure how to use it with Your config.

Is it possible to set this behaving in Your config?

  • "y" to copy text to TMUX's register.
  • "Enter" to copy text to system clipboard
@gpakosz
Copy link
Owner

gpakosz commented Feb 26, 2024

Hello @waldauf 👋

You can add this to your .local customization file:

bind -T copy-mode-vi y send -X copy-selection-no-clear #!important

But after I tested it, even though I set tmux_conf_copy_to_os_clipboard=false, what I copy into tmux buffer is still synced with my OS clipboard and I need to investigate why it's the case with a recent tmux.

@gpakosz
Copy link
Owner

gpakosz commented Feb 26, 2024

Tmux has evolved a lot and according to https://github.com/tmux/tmux/wiki/Clipboard it depends on many factors whether it's going to copy to the OS clipoard.

@waldauf
Copy link
Author

waldauf commented Feb 27, 2024

Hi @gpakosz !
Thank You for Your help. I dived more deeply into it and played with the setting and found this magic configuration which enables me:

  • Stay in copy-mode after copy text, including mouse text marking.
  • y copies to Tmux register.
  • Enter copies to the system clipboard.

Configuration part in .local:

tmux_conf_copy_to_os_clipboard=true
~
###
# Prevent TMUX to leave copy-mode after copying selected text
###
# https://www.fosslinux.com/105809/tmux-copy-paste-mode-tips-and-tricks-for-productivity.htm#block-4
set-option -g default-command "reattach-to-user-namespace -l zsh"

# https://www.reddit.com/r/tmux/comments/v73005/how_to_prevent_tmux_from_exiting_copy_mode_after/
# https://unix.stackexchange.com/questions/639288/retain-selection-highlight-after-copying-text-to-clipboard-in-tmux
bind -T copy-mode-vi y send -X copy-selection-no-clear
bind-key -Tcopy-mode-vi Enter send -X copy-selection-no-clear
bind-key -Tcopy-mode-vi MouseDragEnd1Pane send -X copy-selection-no-clear

@waldauf waldauf closed this as completed Feb 27, 2024
@gpakosz
Copy link
Owner

gpakosz commented Feb 27, 2024

You don't need reattach-to-user-namespace as of tmux 2.6

@waldauf
Copy link
Author

waldauf commented Feb 27, 2024

Now I verified that it doesn't work according to my wish. Everything is also stored in the system clipboard. I hope my future-self will fix it. :D

You don't need reattach-to-user-namespace as of tmux 2.6

I have to run on MacOS and there was a problem without reattach-to-user-namespace. Will try it again without.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants