Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to get gVim (on windows) to execute external commands in cygwin by default? i.e. !ps will open a cygwin terminal showing the currenty running processes?

share|improve this question
up vote 3 down vote accepted

First you need to tell Vim to run the bash program instead of cmd.exe, and bash needs to run as a login shell so that it will read the profile/login scripts and set up the environment (PATH, etc) properly.

You also need to change the setting that introduces command-line options to the shell:

:set shell=C:\Cygwin\bin\bash.exe\ -login
:set shellcmdflag=-c

If your cygwin commands require arguments, you should probably also

:set shellquote=\"

to ensure that the whole command gets wrapped up in quotes properly, otherwise the shell will only get the first word and ignore the rest.

share|improve this answer
Thanks for this. Very helpful – Rich Ashworth Apr 17 '12 at 12:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .