I’d like to add something to my config that helps me to run scripts:
Ideally I’d want something that discovers the scripts (for example bash scripts in some folders and npm scripts) and lists them in a telescope window.
Then from the telescope window, I’d want to start them with toggleterm.
For now I have some hard code things in toggleterm like:
local npm_run_dev = Terminal:new({
cmd = "npm run dev",
hidden = true,
direction = "float",
on_open = function(term)
vim.api.nvim_buf_set_keymap(term.bufnr, "t", "q", "<cmd>close<CR>", {noremap = true, silent = true})
end,
})
function _npm_run_dev_toggle()
npm_run_dev:toggle()
end
but I want to fill these automatically.
So I think I need some things:
- a way to find all bash scripts in some folders
- a way to find all npm scripts
- populate telescope with this
- tell telescope to execute the script with a
Terminal:new
like command. Ideally thetoggle
function, so that long running script get reopened instead of started again.
I guess this should be possible, but I have no idea on how to build something like this. Can anyone help or point me in the right direction?
Thansk