Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash Commands from vim

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?

like image 454
isaacsloan Avatar asked Feb 12 '13 20:02

isaacsloan


2 Answers

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.

like image 139
Kent Avatar answered Sep 23 '22 15:09

Kent


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.

like image 40
Ingo Karkat Avatar answered Sep 19 '22 15:09

Ingo Karkat