mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
feat(terminal): close shell terminals automatically
When starting a terminal buffer that uses the default value of &shell (e.g. when using `:terminal` or `termopen([&shell])`), automatically close the buffer if the shell exits without an error.
This commit is contained in:
@@ -8502,6 +8502,16 @@ static void f_termopen(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
|
|
||||||
channel_terminal_open(curbuf, chan);
|
channel_terminal_open(curbuf, chan);
|
||||||
channel_create_event(chan, NULL);
|
channel_create_event(chan, NULL);
|
||||||
|
|
||||||
|
do_cmdline_cmd("augroup nvim_terminal_close");
|
||||||
|
do_cmdline_cmd("autocmd! TermClose <buffer> "
|
||||||
|
" if !v:event.status |"
|
||||||
|
" let info = nvim_get_chan_info(&channel) |"
|
||||||
|
" if info.argv ==# [&shell] |"
|
||||||
|
" exec 'bdelete! ' .. expand('<abuf>') |"
|
||||||
|
" endif |"
|
||||||
|
" endif");
|
||||||
|
do_cmdline_cmd("augroup END");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// "timer_info([timer])" function
|
/// "timer_info([timer])" function
|
||||||
|
Reference in New Issue
Block a user