1

After causing an infinite recursion by putting

vim -c ':term ++curwin'

in my ~/.bashrc, I wonder if there's a way to do it that actually works.

I know for tmux there's this solution: How can I set my default shell to start up tmux

But in vim-terminal the $TERM variable stays the same.

Panki
  • 6,664
  • Depending on your version, you could check the VIM_TERMINAL environment variable. See https://superuser.com/questions/1399061/how-to-differentiate-vim-terminal-from-regular-terminal-in-bash. – Torin Mar 26 '22 at 19:51

1 Answers1

2

The variable VIM_TERMINAL gets set when you are using the terminal inside vim. See the output of env inside vim terminal vs. outside.

So you can check for this being unset in your .bashrc and launch vim afterwards:

[ -z "$VIM_TERMINAL" ] && vim -c ":term ++curwin"
Panki
  • 6,664
  • Is it possible to use conditionals in the vimrc based on this variable or does vim-terminal load the vimrc first and then sets this variable? I want to create terminal-only settings in vimrc – Nimrod Weinberg Mar 27 '22 at 18:26
  • I am not sure about that - but I'd say try it :) Or ask a new question if you get stuck – Panki Mar 30 '22 at 12:01