3
1
When I give a gvim
command in Cygwin, I want it to invoke the gvim I've installed in my Windows.
I tried writing a function in my .bashrc called gvim
that invokes the gvim.exe in my Program Files folder, using cygpath
and all that, but the problem is, that apparently invokes the gvim with Cygwin's environment; :echo $HOME
prints C:\cygwin\home\Sundar instead of C:\Users\Sundar, and :diffsplit
reports failures in creating temporary files which I assume are related to the same. So, how can I invoke gvim from Cygwin but make it as if it was invoked through, say, the Start menu?
I tried changing the command to pass the gvim path to cmd.exe /c
, but that too somehow sets up the same environment. What do I need to do to make this work?
As an aside, it might be worth your while to use
cygstart
to run the executable, rather than calling it directly...HOME=/cygdrive/c/Users/Sundar cygstart /path/to/gvim.exe
– Costa – 2013-08-01T14:29:26.133I didn't know about
cygstart
, that's hugely useful, thanks. I didn't want the gVim process dependent on the presence of the Cygwin, that's one reason I mentioned "as if it was invoked through the Start menu". Regarding the environment, I'm trying to find out which all I need to set in addition to $HOME. I tried setting TEMP and TMP but am still getting the "Cannot read or write temp files" and "Cannot create diffs" errors. – sundar - Reinstate Monica – 2013-08-01T16:15:49.783If you do
:echo $TEMP
in gVim when run from Windows Explorer and from Cygwin, do you get different paths? – Costa – 2013-08-01T17:18:46.967Strangely, no, in both cases $TEMP and $TMP are both "C:\Users\Sundar\AppData\Local\Temp". But diffsplit works when run from Explorer but not when run from cygwin using "env TMP=C:/Temp/ TEMP=C:/Temp/ HOME=C:/Users/Sundar/ /usr/bin/cygstart 'C:\Program Files (x86)\Vim\vim73\gvim.exe'" (also looks like these values of TMP and TEMP are getting overwritten by Vim automatically!) – sundar - Reinstate Monica – 2013-08-01T19:12:49.840
Hmm, perhaps it's a permissions difference then. Maybe your Cygwin instance is running as a different user, or maybe the shortcut or shell you're running from Explorer are being run as Administrator. That's the best I can theorize without being able to get my hands on your workstation. Hope you figure it out! – Costa – 2013-08-01T19:20:06.293
Phew... After running the diffsplit commands dozens of times (since the command window vanishes so quickly), I was able to see that running from windows uses
cmd.exe /c
whereas running from cygwin usesbash -e
. Turns out it's the value of theset shell
variable that was the culprit. I now have to track down how that's getting set and what else is screwed up like this, but at least this mystery is solved. :) – sundar - Reinstate Monica – 2013-08-01T20:16:36.373