When I run bash commands from inside of vim I notice that the path is all wrong. Is there a way inside of my .vimrc to have it load my .bash_profile or just inherit the PATH and alias settings from the terminal it's launched from?
if you define the shell as interactive, vim will load your .bashrc or .bash_profile. Default it is not loaded.
This can be done by:
:set shellcmdflag=-ic
default is only -c
, :h shellcmdflag
to see detail. of course you could add it in your .vimrc file.
If you've properly done export PATH
in your profile, Vim should inherit the shell's PATH
setting. You can check via :echo $PATH
from inside Vim, and also manipulate it via :let $PATH .= ':/additional/path'
.
If you also need aliases, you have to use Kent's solution. A word of caution: With this modification of 'shellcmdflag'
, you may (depending on the complexity of your shell environment) incur a runtime penalty for every shell invocation from Vim.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With