I’m trying to create a function that run some commands in terminal and I want it to show the output of terminal in a new split window.
I’m using Neovim, (and spacemacs).
function Gpt(prompt)
" Get the full path of the current buffer
let file = expand('%:p')
" Open a vertical split with a terminal
split new
wincmd k " Focus the newly opened window
setlocal nobuflisted
" setlocal bufhidden=wipe
setlocal noswapfile
call termopen('echo ' . a:prompt . ' | cat - ' . file . ' | tgpt')
startinsert
endfunction
the problem is the window that has the output will be immediately closed if you press any keys! unless you click on it with your mouse.