Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to start a windows GUI program in cygwin?

I have gVim installed in my Win7 and I am using cygwin a lot.

When I am in cygwin bashell I want to enter "vim aaa.c" and then let my Windows program gVim open aaa.c for me.

Would anyone tell me to do what configuration then this could work?

Typing "notepad" directly in cygwin shell and pressing enter works. I know "notepad" can be found in Windows' system variable "path" so it works. I have tried adding my gVim.exe's path to system variable "path" but it doesn't work.

PS: if you type "run notepad" in cygwin shell it also starts Windows notepad. But how to make my gVim recognized by cygwin just like 'notepad'? I don't want to type the full installation path to my gVim in cygwin shell every time.

Thanks!

like image 688
actan Avatar asked Feb 19 '13 07:02

actan


People also ask

Does Cygwin have GUI?

XLaunch is a GUI wizard for starting the Cygwin/X X server and a local or remote X client. These sessions can be saved and shared as . xlaunch files. XLaunch is included in the xlaunch package (installed by following the instructions in the Section called Installing Cygwin/X in Chapter 2).


1 Answers

The easiest solution is to add the following line in your .bashrc

alias vim="/cygdrive/c/Program\ Files\ \(x86\)/vim/vim73/gvim.exe"

when invoking vim do vim foo.txt &, the & ensures the process is run in the background so your shell is still usable before the process ends.

if you do not want to type the & every time, do the following alias

alias vim="cygstart /cygdrive/c/Program\ Files\ \(x86\)/vim/vim73/gvim.exe"

The best solution though is to install cygwin vim instead of using the windows version. With the windows one, you will fight with the path conversion all the time. Really you want it to work for all the followings:

vim ~/foo
vim /bar
vim $home/abc
vim /cygpath/c/def
vim "c:\ghi"

There are some complicated shell scripts which help ease the problem, but I have not come across any that does not have certain caveat.

like image 169
Xuan Avatar answered Oct 02 '22 00:10

Xuan