kitty-scrollback.nvim icon indicating copy to clipboard operation
kitty-scrollback.nvim copied to clipboard

feat: add option: close_after_yank

Open EmmetZ opened this issue 8 months ago • 2 comments

Could we have a close_after_yank setting in the default config? It would default to true but let users choose their preferred behaviour.


use case: sometimes I want to copy multiple words and paste them in different places, but once I yank the first word, scrollback buffer automatically closes and I have to relaunch it again to yank the rest.

I get this idea from Alacritty since it won't quit vim mode after a yank operation. (Thanks for this awesome plugin. Now I can use vim mode in Kitty just like in Alacritty but with even more features!)

posible solution:

in lua/kitty-scrollback/configs/defaults.lua:

@@ -62,6 +63,7 @@ local default_opts = {
   keymaps_enabled = true,
   restore_options = false,
   highlight_overrides = nil,
+  close_after_yank = true,
   status_window = {
     enabled = true,
     style_simple = false,

in lua/kitty-scrollback/autocommands.lua:

@@ -154,9 +154,11 @@ M.set_yank_post_autocmd = function()
             -- see issue https://github.com/astrand/xclip/issues/38#ref-commit-b042f6d
             defer_ms = 200
           end
-          vim.defer_fn(function()
-            ksb_util.quitall()
-          end, defer_ms)
+          if opts.close_after_yank then
+            vim.defer_fn(function()
+              ksb_util.quitall()
+            end, defer_ms)
+          end
         else

Do you think this is appropriate :) ?

EmmetZ avatar May 01 '25 06:05 EmmetZ

@EmmetZ This seems reasonable to me. Is your use case, you copy some text from the scrollback buffer and then past it in another window/program then come back and select different text?

I typically work in the same window so didn't think about this scenario with multiple yanks.

mikesmithgh avatar Jun 25 '25 17:06 mikesmithgh

Sorry for the late reply.


Is your use case, you copy some text from the scrollback buffer and then past it in another window/program then come back and select different text?

Yes in my use case sometimes I need multiple yanks. For example when one command goes wrong and I don't know why. I need to copy the command and the error log and ask google or llm. But there might be other outputs which are useless between the command I enter on the command line and the actual error messages, in which case I need to multiple yanks.

EmmetZ avatar Jun 29 '25 12:06 EmmetZ