local BUILD_COMMAND = "" ---@param command string ---@return nil function executeCommandInTerminal(command) 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") end function setBuildCommand() BUILD_COMMAND = vim.fn.input("Enter compile command: ", BUILD_COMMAND) end function build() if string.len(BUILD_COMMAND) == 0 then setBuildCommand() end if string.len(BUILD_COMMAND) > 0 then vim.cmd.term() vim.cmd.startinsert() executeCommandInTerminal(BUILD_COMMAND) end end vim.keymap.set("n", "mc", setBuildCommand) vim.keymap.set("n", "mt", build)