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

kitty +kitten clipboard -g should not read stdin #6302

Closed
peterwu opened this issue May 24, 2023 · 6 comments
Closed

kitty +kitten clipboard -g should not read stdin #6302

peterwu opened this issue May 24, 2023 · 6 comments
Labels

Comments

@peterwu
Copy link

peterwu commented May 24, 2023

Describe the bug
According to the documentation, kitty +kitten clipboard --get-clipboard can be used to get text from clipboard. However, if stdin is passed, it will continue to set the content of stdin to the clipboard before returning the newly set content.

To Reproduce
Steps to reproduce the behavior:

  1. kitty +kitten clipboard <<< "test"
  2. kitty +kitten clipboard -g # this correctly returns test
  3. kitty +kitten clipboard -g <<< "test again"
  4. kitty +kitten clipboard -g # this incorrectly returns test again

Additional context
kitty 0.28.1 on Fedora 38

@peterwu peterwu added the bug label May 24, 2023
@kovidgoyal
Copy link
Owner

I dont understand the issue. As the docs say, in filter mode, the kitten
reads from STDIN to set keyboard and additionally can be made to write
to STDOUT the contents of the clipboard. If you dont want to set the
clipboard dont send anything to STDIN or redirect it to /dev/null

If there is some problem I am not seeing feel free to comment further.

@peterwu
Copy link
Author

peterwu commented May 25, 2023

The problem actually rose from a piece of vimscript I tried to write:

nnoremap <leader>t :echo system('kitty +kitten clipboard -g')<CR>

The intention is that when I hit <leader>t, vim will echo the clipboard content. However, this doesn't work and the clipboard content is actually wiped out.

@kovidgoyal
Copy link
Owner

Use

kitten clipboard -g /dev/stdout

@peterwu
Copy link
Author

peterwu commented May 25, 2023

Use

kitten clipboard -g /dev/stdout

I've already tried this with some side effect. :-)

If you, in another kitty terminal, do this: kitten clipboard <<< "test" or use xsel xsel -ib <<< "test", the string "test" will be placed into the clipboard. Good. However, if you now go back to vim, and run the system("kitten clipboard -g /dev/stdout"), you will get an error Error: The MIME type text/plain for /dev/stdout not available on the clipboard.

But, if you go to an X11 application, say FireFox, and copy some text there and go back to the vim session, then kitten clipboard -g /dev/stdout works without complaints.

I am quite sure kitten clipboard -g used to work under v0.26.5 but stopped working under 0.28.0 and 0.28.1.

@kovidgoyal
Copy link
Owner

Works for me with

kitten clipboard <<< test
kitten clipboard -g /dev/stdout # outputs test as expected

Your issue is likely caused by the bug fixed in 73f10aa

However, thinking about it, I suppose even in filter mode
--get-clipboard should only get and not set the clipboard. This makes it
easier to use and also the two modes have the same semantics.

@peterwu
Copy link
Author

peterwu commented May 25, 2023

kitten clipboard <<< test
kitten clipboard -g /dev/stdout # outputs test as expected

If you run these 2 commands in shell, then no problem; the problem only occurs in the context of vimscript.

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

No branches or pull requests

2 participants