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.

For some reason it seems that vim (installed through macports: VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Feb 25 2013 01:56:26) prefixes my $PATH variable with the /etc/paths files.

Although I don't mind it adding those, it is very convenient that it is prefixing my path with that in all cases in a way that I cannot override it (or at least, I haven't found a way to do so).

Example of the problem:

" First we overwrite $PATH with something to show the problem
:let $PATH='just_some_non_existing_dir'

" Now print the path in the shell to show the problem (note the !)
:!echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:just_some_non_existing_dir

How can I prevent Vim from prefixing this $PATH for every external command I execute?

A little information about my environment:

OS X: 10.8.2 VIM: Vi IMproved 7.3 (2010 Aug 15, compiled Feb 25 2013 01:56:26) zsh: 4.3.11 (i386-apple-darwin12.0)

Note that I run zsh as a shell.

share|improve this question
2  
Does :set shellcmdflag? include -l? That would launch a login shell and source the profile again. –  Ingo Karkat Mar 1 '13 at 16:08
2  
Vim is not the culprit. Your shell is. –  romainl Mar 1 '13 at 16:28
    
@IngoKarkat: no, it's at the default shellcmdflag=-c –  Wolph Mar 1 '13 at 16:41
    
@romainl: How so? The path in my shell (before I type vim) doesn't include this (or at least, has different paths before this section) –  Wolph Mar 1 '13 at 16:41
1  
After a little research from both your hints I found the problem, apparently the default behaviour of zsh is similar to bash -l cause it's overwriting my path with things from my local path settings. My shell was indeed the culprit, what I can't figure out is how this just changed recently. I never had this problem but I'm not sure when it changed. –  Wolph Mar 1 '13 at 16:55

1 Answer 1

up vote 1 down vote accepted

Thanks to the great help of @IngoKarkat and @romaini I found the solution. Here's some info for people to debug this problem:

# To figure out which shell Vim is executing:
:set shell
:set shellcmdflag
# The response of these 2 concatenated are what will be executed by Vim

Now, once you know what it's running, exit Vim and execute it in your local shell to see what the results are (in my case, "zsh -c"):

# zsh -c 'echo $PATH'

If this is wrong, it could be something in your .zshrc, .profile, /etc/profile, /etc/zsh/zshrc, /etc/zshrc or one of the many other files.

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.