added some custom fucntions and a new api
This commit is contained in:
23
lua/custom-functions.lua
Normal file
23
lua/custom-functions.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
-- lua/custom-functions.lua
|
||||
-- A library file with custom functions for cleaner code elsewhere
|
||||
|
||||
local C = {}
|
||||
function C.runLastCommand()
|
||||
-- TODO fix implementation
|
||||
local term = require("toggleterm.terminal").get(1)-- Get terminal ID 1
|
||||
-- Save position and buffer context
|
||||
if term then
|
||||
local original_window = vim.api.nvim_get_current_win()
|
||||
local saved_view = vim.fn.winsaveview()
|
||||
-- Using \r (carriage return) or \n\n often bypasses shell interceptors
|
||||
-- term:send("clear\r")
|
||||
term:send("test_dev.sh\r")
|
||||
vim.api.nvim_set_current_win(original_window)
|
||||
vim.fn.winrestview(saved_view)
|
||||
else
|
||||
vim.notify("Terminal 1 is not open yet!", vim.log.levels.WARN)
|
||||
end
|
||||
-- Return logic
|
||||
end
|
||||
|
||||
return C
|
||||
Reference in New Issue
Block a user