diff options
| author | Aotrix <[email protected]> | 2026-06-03 21:02:19 +0200 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2026-06-03 21:02:19 +0200 |
| commit | 1f0ab79a26a3bfc396f8fa09a1acda0df2d2fec3 (patch) | |
| tree | e9de139009b6797da4d3fe507c19828a96688dc8 /lua/aotrix/build.lua | |
| parent | 9a6d1d677283ce759d0317efffa0451d57737ffe (diff) | |
Create temporary command
Diffstat (limited to 'lua/aotrix/build.lua')
| -rw-r--r-- | lua/aotrix/build.lua | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lua/aotrix/build.lua b/lua/aotrix/build.lua index c429467..35d9675 100644 --- a/lua/aotrix/build.lua +++ b/lua/aotrix/build.lua @@ -1,16 +1,19 @@ -local CURRENT_COMMAND = "" +local CURRENT_COMMAND = nil ----@param command string +---@param command string|nil ---@return nil function executeCommandInTerminal(command) - vim.cmd.term() - vim.cmd.startinsert() - local channel = vim.bo.channel - -- 'clear' is used to hide the command - local exit_message = "\nPress enter to exit..." - vim.api.nvim_chan_send(channel, - "clear && " .. command .. "; echo '" .. exit_message .. - "' && read -s && exit" .. "\n") + if (command ~= nil) then + vim.cmd.term() + vim.cmd.startinsert() + local channel = vim.bo.channel + -- 'clear' is used to hide the command + local exitMessage = "\nPress enter to exit..." + local commandString = command() + vim.api.nvim_chan_send(channel, + "clear && " .. commandString .. "; echo '" .. + exitMessage .. "' && read -s && exit" .. "\n") + end end local COMMANDS = {} @@ -29,14 +32,14 @@ function selectCommand(listOfCommands, callback) end }, function(choice) if (choice ~= nil) then - CURRENT_COMMAND = listOfCommands[choice].command() + CURRENT_COMMAND = listOfCommands[choice].command callback() end end) end function executeCommand(listOfCommands) - if (string.len(CURRENT_COMMAND) == 0) then + if (CURRENT_COMMAND == nil) then selectCommand(listOfCommands, function() executeCommandInTerminal(CURRENT_COMMAND) |
