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

replacement for "bind-key -t vi-copy 'y' copy-selection" ? #910

Closed
bedge opened this Issue May 4, 2017 · 14 comments

Comments

8 participants
@bedge
Copy link

bedge commented May 4, 2017

What's the 'new' keybinding replacement for the following?

bind-key -t vi-copy 'y' copy-selection

Specifically, I have:

set-window-option -g mode-keys vi
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection

I'm not a tmux whiz, but it is embedded in my workflow and this is a blocking issue.

thanks in advance.

@bedge

This comment has been minimized.

Copy link
Author

bedge commented May 4, 2017

I've tried some of the new default bindings, ie:

bind-key    -T copy-mode-vi C-j               send-keys -X copy-selection-and-cancel

It does clear the selection highlight, but doesn't impact my clipboard at all.

I'm using:

reattach-to-user-namespace version 2.5

ie:

set -g default-command "reattach-to-user-namespace -l ${SHELL}"
@bedge

This comment has been minimized.

Copy link
Author

bedge commented May 4, 2017

This kinda works:

bind-key -T copy-mode-vi 'v' send-keys -X begin-selection
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe 'reattach-to-user-namespace pbcopy'

Except that it requires 'y' AND '' to copy.

@nicm

This comment has been minimized.

Copy link
Contributor

nicm commented May 5, 2017

Replacement for:
bind-key -t vi-copy 'y' copy-selection
Is:
bind-key -T copy-mode-vi 'y' send-keys -X copy-selection

@bedge

This comment has been minimized.

Copy link
Author

bedge commented May 5, 2017

Perfect.
Thanks from all the tmux/vi-keymap users that only read the docs when stuff breaks and even then need help.

Just a thought - a migration doc may not be a bad thing when changes of this magnitude are released. I know the README had some info, but it was emacs specific and there's a lot more that's different now besides just the keymap stuff.

@bedge bedge closed this May 5, 2017

@rawaludin

This comment has been minimized.

Copy link

rawaludin commented May 6, 2017

@bedge Is
bind-key -T copy-mode-vi 'y' send-keys -X copy-selection

Will put yanked text to osx clipboard too?

Mine don't.

I used this to put yanked text to osx clipboard too:
bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe 'reattach-to-user-namespace pbcopy'

But the selection won't clear after I press y.

Any idea?

@delphinus

This comment has been minimized.

Copy link

delphinus commented May 6, 2017

You may use copy-pipe-and-cancel instead of copy-pipe.

But, if you only want to yank by tmux, you do not need reattach-to-user-namespace.

(And you should check on Application in terminal may access clipboard setting in iTerm2)

bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel

@bedge bedge reopened this May 6, 2017

@bedge

This comment has been minimized.

Copy link
Author

bedge commented May 6, 2017

@rawaludin yeah, it's not working consistently. It worked right when I 1st tried it, but it's not now.

@delphinus I use my clipboard to transfer between apps, so I believe the reattach-to-user-namespace is needed.

@nicm

This comment has been minimized.

Copy link
Contributor

nicm commented May 7, 2017

@nabin-info

This comment has been minimized.

Copy link

nabin-info commented May 7, 2017

FYI, the builtin bind-key commands are defined in key-bindings.c

@bedge

This comment has been minimized.

Copy link
Author

bedge commented May 9, 2017

Here's the final working config (that clears selection mode with 'y'):

bind-key -T copy-mode-vi 'y' send-keys -X copy-pipe-and-cancel 'reattach-to-user-namespace pbcopy'

Didn't pick up on the subtle hints 1st time around.

@bedge bedge closed this May 9, 2017

@asarbu

This comment has been minimized.

Copy link

asarbu commented Oct 3, 2017

I tried changing some bindings, but it doesn't seem to do anything.

bind-key -T copy-mode C-x send-keys -X copy-selection-and-cancel
bind-key -T copy-mode-vi C-x send-keys -X copy-selection-and-cancel

When I select a text and hit C-x, nothing happens, but when I try C-w (default key binding) the text is copied and I can paste it using C-b, ].

Can somebody help me figure this out ?

dleve123 added a commit to dleve123/dotfiles that referenced this issue Dec 2, 2017

Fix and update tmux-macOS copy+paste interface
- Update command invocations to support tmux 2.6
  + `bind -t` -> `bind -T`
  + `vi-copy` -> `vi-copy-mode`
  + used `send-keys -X` in `bind` invocations
- Update behavior of `y` and `Enter` when in copy-mode-vi
  + `y` will copy to system clipboard, but won't exit copy-mode
  + `Enter` will copy to system clipboard and will exit copy-mode

The below helped me debug this issue:

- This Github issue [comment][0]
- The tmux [changelog][1]

Potential Follow Up:
- Email to thoughtbot suggesting that they update [this blog post][2]

[0]:tmux/tmux#910 (comment)
[1]:https://github.com/tmux/tmux/blob/e58d16b2df52beefd5094ac61bb9e44c123df3e7/CHANGES
[2]:https://robots.thoughtbot.com/tmux-copy-paste-on-os-x-a-better-future

dleve123 added a commit to dleve123/dotfiles that referenced this issue Dec 2, 2017

Fix and update tmux-macOS copy+paste interface
- Update command invocations to support tmux 2.6
  + `bind -t` -> `bind -T`
  + `vi-copy` -> `vi-copy-mode`
  + used `send-keys -X` in `bind` invocations
- Update behavior of `y` and `Enter` when in copy-mode-vi
  + `y` will copy to system clipboard, but won't exit copy-mode
  + `Enter` will copy to system clipboard and will exit copy-mode

The below helped me debug this issue:

- This Github issue [comment][0]
- The tmux [changelog][1]

Potential Follow Up:
- Email to thoughtbot suggesting that they update [this blog post][2]

[0]:tmux/tmux#910 (comment)
[1]:https://github.com/tmux/tmux/blob/e58d16b2df52beefd5094ac61bb9e44c123df3e7/CHANGES
[2]:https://robots.thoughtbot.com/tmux-copy-paste-on-os-x-a-better-future
@rjhilgefort

This comment has been minimized.

Copy link

rjhilgefort commented May 29, 2018

@bedge I'm not seeing what copy-pipe-and-cancel adds- my selection is cleared with just copy-pipe. What's the difference?

@bedge

This comment has been minimized.

Copy link
Author

bedge commented May 29, 2018

@rjhilgefort IIRC this was right after I upgraded to tmux 2.x
At the time, just using copy-pipe wasn't clearing selection. From your comment I expect this may have changed.

@sursh

This comment has been minimized.

Copy link

sursh commented Sep 18, 2018

Yay thank you! And here's the command for begin-selection that's now working for me:

bind-key -T copy-mode-vi 'v' send-keys -X begin-selection

BigCrunsh added a commit to BigCrunsh/dotfiles that referenced this issue Jan 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.