From 376d87273a64caf02f2646a5ebaaf3c6d9e5e5b4 Mon Sep 17 00:00:00 2001 From: Mike Smith <10135646+mikesmithgh@users.noreply.github.com> Date: Thu, 30 Nov 2023 14:27:30 -0500 Subject: [PATCH 1/3] feat: clear selection in kitty after paste --- lua/kitty-scrollback/kitty_commands.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lua/kitty-scrollback/kitty_commands.lua b/lua/kitty-scrollback/kitty_commands.lua index 46a72e34..d184fca2 100644 --- a/lua/kitty-scrollback/kitty_commands.lua +++ b/lua/kitty-scrollback/kitty_commands.lua @@ -221,21 +221,29 @@ M.get_text_term = function(kitty_data, get_text_opts, on_exit_cb) vim.o.shell = p.orig_options.shell end -M.send_paste_buffer_text_to_kitty_and_quit = function(bracketed_paste_mode) +M.send_paste_buffer_text_to_kitty_and_quit = function(execute_command) -- convert table to string separated by carriage returns local cmd_str = table.concat( vim.tbl_filter(function(l) - return #l > 0 + return #l > 0 -- remove empty lines end, vim.api.nvim_buf_get_lines(p.paste_bufid, 0, -1, false)), '\r' ) - -- wrap in bracketed paste mode local esc = vim.fn.eval([["\e"]]) - cmd_str = esc .. '[200~' .. cmd_str .. '\r' .. esc .. '[201~' -- see https://cirw.in/blog/bracketed-paste - -- if not bracketed paste mode trigger add a carriage return to execute command - if not bracketed_paste_mode then + local enquiry = '\x05' -- see https://en.wikipedia.org/wiki/Enquiry_character + local start_bracketed_paste = esc .. '[200~' -- see https://cirw.in/blog/bracketed-paste + local stop_bracketed_paste = esc .. '[201~' -- see https://cirw.in/blog/bracketed-paste + + -- the beginning enquiry is used to separate any existing commands in kitty that may end with escape + -- if escape is present, then bash autocompletion will be triggered because bracketed paste mode starts with an escape + -- the ending enquiry is used to remove deselect the text after pasting to the terminal + cmd_str = enquiry .. start_bracketed_paste .. cmd_str .. stop_bracketed_paste .. enquiry + + if not execute_command then + -- add a carriage return to execute command cmd_str = cmd_str .. '\r' end + system_handle_error({ 'kitty', '@', From 72a9f78e6f0d3d38f36281bf0c675faf3b91a944 Mon Sep 17 00:00:00 2001 From: Mike Smith <10135646+mikesmithgh@users.noreply.github.com> Date: Thu, 30 Nov 2023 20:38:25 -0500 Subject: [PATCH 2/3] chore: update contributing --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index acff4ec3..6e59f687 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,6 +4,7 @@ - `git clone git@github.com/mikesmithgh/kitty-scrollback.nvim.wiki.git` - `cd kitty-scrollback.nvim.wiki` +- `./scripts/record_main_demo.lua` - `./scripts/record_demo_videos.lua` - `ls -1 assets/*.mov | xargs -I {} scripts/mov_to_gif.sh {}` - Upload all `mov` files in the `assets` directory to Github by dragging them to a markdown file in the browser From 39fc34e1c40243fc3828967f710448788f0e11bc Mon Sep 17 00:00:00 2001 From: Mike <10135646+mikesmithgh@users.noreply.github.com> Date: Thu, 30 Nov 2023 20:42:35 -0500 Subject: [PATCH 3/3] chore: update main demo --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 84ec203b..f069b998 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ Navigate your Kitty scrollback buffer to quickly search, copy, and execute comma - - - kitty-scrollback.nvim demo + + + kitty-scrollback.nvim demo
(click for video)