1

After :terminal runs, is there a way within Vim script to determine the type of shell that started with creation of the terminal ? within Vimscript, NOT via OS commands such as ps.

3

From :help :terminal,

        If [command] is not given the 'shell' option is used.

So you can retrieve the shell executable which will be run with &shell.

If you want to get the command line used to start the terminal, irrespective of 'shell', just use the buffer name, e.g.,

let l:terms = term_list()
let l:bufname = empty(l:terms) ? '' : bufname(l:terms[-1])
let l:shell = substitute(l:bufname, '^!', '', 'g')
  • Thanks Mass. I asked the question b/c the quoted section from :help does not account for the scenario when [command] specs a shell, and your 2nd approach is what I was looking for. – cesces Feb 18 '18 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.