0

I have a small .bat file to open Vim along with a terminal running an IPython console:

@echo off
call C:\Users\myname\Miniconda3\condabin\activate.bat C:\Users\myname\Miniconda3\envs\myenv
gvim -c "vert botright terminal C:\Users\myname\Miniconda3\condabin\conda.bat activate myenv  &&echo Conda env:%CONDA_DEFAULT_ENV%  &&ipython"

I am fairly happy, but the name of the terminal buffer is fairly annoying:

C:\Users\myname\Miniconda3\condabin\conda.bat activate myenv...

Hence, I manually change the name of such a terminal by putting the focus on the terminal buffer and by issuing <c-W>:file IPYTHON but this is very boring and error prone.

A solution would be to automatically run the command :file IPYTHON after I launched :terminal but from the documentation that does not seems to be possible.

How can I solve my problem then? Shall I modify my .vimrc file? If so, how?

1 Answer 1

1

Instead of executing the command :terminal, we can use the function term_start which provides us with several optional options, one of which lets us set the buffer name.

From :h term_start:

term_start({cmd} [, {options}])         *term_start()*
        Open a terminal window and run {cmd} in it.
        <snip>         
        There are extra options:
           "term_name"       name to use for the buffer name, instead
                     of the command name.
           <snip>

Using the above, we can refactor OP's batch script accordingly:

@echo off
call C:\Users\myname\Miniconda3\condabin\activate.bat C:\Users\myname\Miniconda3\envs\myenv
gvim -c "vert botright call term_start('C:\\Users\\myname\\Miniconda3\\condabin\\conda.bat activate myenv && echo Conda env:%CONDA_DEFAULT_ENV% && ipython', {'term_name': 'IPython'})"
1
  • Solved! Thanks!
    – Barzi2001
    Oct 9, 2022 at 13:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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