From 51a6f4f2497528820855c7ef3f8830e0438b2078 Mon Sep 17 00:00:00 2001 From: pika Date: Mon, 17 Mar 2025 17:43:31 +0100 Subject: [PATCH] add: addet keymap to insert command output directly --- lua/pika/core/keymaps.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lua/pika/core/keymaps.lua b/lua/pika/core/keymaps.lua index 633eb1c..0a54da3 100644 --- a/lua/pika/core/keymaps.lua +++ b/lua/pika/core/keymaps.lua @@ -61,3 +61,22 @@ map("n", "R", [[:%s/\<\>//gI]]) -- window management map("n", "sv", "v", { desc = "Split window vertically" }) -- split window vertically map("n", "sh", "s", { desc = "Split window horizontally" }) -- split window horizontally + +vim.keymap.set({ "n", "v" }, "tt", function() + -- Frage den Shell-Command ab + vim.ui.input({ prompt = "Shell Command: " }, function(cmd) + if cmd == nil or cmd == "" then + return + end + + local handle = io.popen(cmd) + local result = handle:read("*a") + handle:close() + + local lines = vim.split(result, "\n", { trimempty = true }) + + -- Einfügen an Cursor-Position + local row, col = unpack(vim.api.nvim_win_get_cursor(0)) + vim.api.nvim_buf_set_lines(0, row, row, false, lines) + end) +end, { desc = "Insert Shell Output at Cursor" })