add: addet keymap to insert command output directly
This commit is contained in:
parent
37c84420c1
commit
51a6f4f249
1 changed files with 19 additions and 0 deletions
|
@ -61,3 +61,22 @@ map("n", "<leader>R", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
|
|||
-- window management
|
||||
map("n", "<leader>sv", "<C-w>v", { desc = "Split window vertically" }) -- split window vertically
|
||||
map("n", "<leader>sh", "<C-w>s", { desc = "Split window horizontally" }) -- split window horizontally
|
||||
|
||||
vim.keymap.set({ "n", "v" }, "<leader>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" })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue