3

When I'm shelling out some external command using !

:r !pbpaste

or

:!./path/to_my_script

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?

1
  • Did you try :!env? – wchargin Feb 3 '15 at 22:10
4

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.

3

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, privacy policy and cookie policy

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