Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to call some shell command from vim with like :!ls command. But unfortunately there are some default PATHS that prepends PATHs defined in the original shell. Here is the echo $PATH output in the original shell:

/usr/local/heroku/bin:/Users/bogdan/.rvm/gems/ruby-1.9.3-p194/bin:/Users/bogdan/.rvm/gems/ruby-1.9.3-p194@global/bin:/Users/bogdan/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/bogdan/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/Users/bogdan/.rvm/bin:/Users/bogdan/bin:/Users/bogdan/.rvm/bin:/usr/local/Cellar/git/1.7.12.2/libexec/git-core:/Users/bogdan/.rvm/bin

and shell called within vim:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/Users/bogdan/.rvm/gems/ruby-1.9.3-p194@devauc/bin:/Users/bogdan/.rvm/gems/ruby-1.9.3-p194@global/bin:/Users/bogdan/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/bogdan/.rvm/bin:/Users/bogdan/bin:/usr/local/Cellar/git/1.7.12.2/libexec/git-core:/Users/bogdan/.rvm/bin

Why they appeared right there? How can I prevent that and make vim shell has original PATH variable.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

See this answer of mine or this one with a nice table to similar questions. You should check the file in which you setup your custom $PATH. Whether it's ~/.profile or ~/.bashrc or some other file and the method of invocation of the shell have their role in this.

For reference, I have only one line in my ~/.bashrc:

source ~/.profile

(with all my settings going into ~/.profile) and this line in my ~/.vimrc:

set shell=bash\ -i

The whole thing is not very pretty but it's simple and it works.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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