When I'm shelling out some external command using !

:r !pbpaste



What environment will be used and how to manually configure it? I'm a big fan of ZSH. Can I have some dedicated RC files that similar to my ~/.zshrc and ~/.zprofile and explicitly set zsh as default interpreter?

  • Did you try :!env?
    – wchargin
    Feb 3, 2015 at 22:10

2 Answers 2


TL;DR Vim runs the shell you would expect but in non-interactive mode. See your shell's documentation for non-interactive mode affects initialization, i.e. which init files are read.

Vim uses whatever shell is specified in your environment (either through the $SHELL environment variable or, if that isn't available, your user's entry in /etc/passwd).

That being said, Vim is going to run the shell in non-interactive mode since, well, you're using the shell non-interactively. Shell initialization is different for non-interactive mode vs. interactive mode. One common thing people notice is that they likely won't have aliases available. This is intentional (from the shell's perspective) because scripts shouldn't need aliases.

Now, it's possible to have Vim run your shell in interactive mode by setting the 'shellcmdflag' flag appropriately. That isn't necessarily a good idea, though. Forcing the shell into interactive mode may cause other unintended side effects.


You can add this line to your .vimrc:

set shell=/usr/local/bin/zsh

(or whatever the path is to your zsh install)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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