Sample Header Ad - 728x90

How to paste selection from vi-mode to clipboard

2 votes
0 answers
513 views
I want to access the content of what I copied in the buffer with the vi-mode of the clipboard via the command ctrl + v or ctrl + shift + v in the terminal. I copied in my .zshrc the following: (from this answer: https://unix.stackexchange.com/questions/25765/pasting-from-clipboard-to-vi-enabled-zsh-or-bash-shell)
vi-append-x-selection () { RBUFFER=$(xsel -o -p 
When I highlight something in the terminal in vi-mode and yank it, I can successfully retrieve it by typing Ctrl + shift + y. However when I type Ctrl + shift + v, something else in being pasted. When I inspect the content of the clipboard with the following commands:
xclip -o sel p
xclip -o sel s
xclip -o sel c
xsel -o -p
xsel -o -s
xsel -o -b
it contains other string that I peviously copied with other means but NOT what I highlighted in vi-mode. Here is my **first question**: if I can retrieve it with the command Ctrl + shift + y and confirm that with xsel and xclip that it is not in one of the three buffer ("primary", "secondary" and "clipboard") where is stored then???) I also tried to replace the '^Y' by '^V' in the line
bindkey -a '^Y' vi-yank-x-selection
(as follows:)
bindkey -a '^V' vi-yank-x-selection
Without any success (it seems to print out an empty buffer) **my second question**: What am I doing wrong?
Asked by ecjb (475 rep)
May 26, 2022, 01:25 PM
Last activity: May 27, 2022, 10:16 PM