Is it possible to get gVim to execute external commands in cygwin by default?

4

1

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?

Rich Ashworth

Posted 2012-04-17T09:36:23.337

Reputation: 197

Answers

4

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.

njd

Posted 2012-04-17T09:36:23.337

Reputation: 9 743