Starting Native Windows GVim 8.2 from MinGW Git Bash

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Starting Native Windows GVim 8.2 from MinGW Git Bash

JohannS-2
I finally have a newish Windows 10 64-bit laptop for a course and, per
instructions, have installed Git Bash that uses MinGW from:
https://git-scm.com/downloads

I also have a standard native Window build of GVIm 8.2 installed under:
C:\Program File (x86)\Vim\vim82
which I believe was the default for the standard installer.

MinGW Git Bash ships with a built-in version of vim 8.2 as MinGW program, but
does not include GVim.

What I am looking to do is to start the native Windows version of GVim from a
the Git Bash prompt.  Rather than change the path I hoped to use a simple bash
alias with a full path to start Windows GVim 8.2.  This works except that the
bash prompt blocks as if Windows GVim is a console program and the shell is
waiting to get control back of the console.  I am not entirely sure why the
shell waits for Gvim to exit.  The same technique I am trying to was recommended
for MSysGit Bash and Vim 7.4 by Albert Armea at:
https://blog.albertarmea.com/post/115102365718/using-gvim-from-git-bash
The best reason I can fathom is that I read elsewhere that MinGW is a more
minimalist UNIX implementation than say Cygwin and does not implement fork()
despite providing the header file.  Another possibility is that some trick
integration set up in the bundle for Vim and GVim with Git is inadvertently fighting my
attempt to use a Windows executable.

Due to how Bash is invoked by the Git Bash bundle, the easiest way for me to
configure user specific bash aliases or the like is to create two files:

~/.bash_profile is minimal and contains:

if [ -f ~/.bashrc  ]; then. ~/bashrc; fi

~/.bashrc has my local alias and a bash function gvim () as follows:

gvim () { (env -u HOME -u VIM "/c/Program Files (x86)/vim/vim82/gvim.exe" "$*")& }

Another place on the Internet, I found advice to unset the HOME and VIM
environment variables local to MinGW Bash as Windows GVIm 8.2 is started, but I
converted a simple bash alias to bash function.  While the env command above
would run GVim as a simple alias, the Git Bash shell blocks waiting for GVim to
exit.  The bash function is needed so I can embed the env in a subshell with
parentheses and push it to the background, while still passing parameters to the
inner command line.  This bash function works, starting GVim and letting the
shell continue.  I do notice that this Windows GVim shows up as a process when
using the ps command at the Git Bash prompt.  I am not sure if anything funny
happens, based on the order I close Git Bash and GVim.

I am not sure if this is the best approach.  Another idea I saw on the Internet
suggested using the bash disown built-in command, but I was getting syntax
errors.  I tried debugging with set -x in Git Bash but extra commands I did not
expect were being generated, probably due to Git integration.  I decided that
this method is best, for now, but I am wondering if there are any gotchas
lurking here.

Thanks in advance for any advice.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200514191755.GB1444%40linux.site.
Reply | Threaded
Open this post in threaded view
|

Re: Starting Native Windows GVim 8.2 from MinGW Git Bash

JohannS-2
On Thu, May 14, 2020 at 03:17:55PM -0400, [hidden email] wrote:

>I finally have a newish Windows 10 64-bit laptop for a course and,
>per instructions, have installed Git Bash that uses MinGW from:
>https://git-scm.com/downloads
>
>I also have a standard native Window build of GVIm 8.2 installed under:
>C:\Program File (x86)\Vim\vim82
>which I believe was the default for the standard installer.
>
>MinGW Git Bash ships with a built-in version of vim 8.2 as MinGW
>program, but does not include GVim.
>
>What I am looking to do is to start the native Windows version of
>GVim from a the Git Bash prompt.  Rather than change the path I hoped
>to use a simple bash alias with a full path to start Windows GVim
>8.2.  This works except that the bash prompt blocks as if Windows
>GVim is a console program and the shell is waiting to get control
>back of the console.  I am not entirely sure why the shell waits for
>Gvim to exit.  The same technique I am trying to was recommended for
>MSysGit Bash and Vim 7.4 by Albert Armea at:
>https://blog.albertarmea.com/post/115102365718/using-gvim-from-git-bash
>The best reason I can fathom is that I read elsewhere that MinGW is a
>more minimalist UNIX implementation than say Cygwin and does not
>implement fork() despite providing the header file.  Another
>possibility is that some trick integration set up in the bundle for
>Vim and GVim with Git is inadvertently fighting my attempt to use a
>Windows executable.
>
>Due to how Bash is invoked by the Git Bash bundle, the easiest way
>for me to configure user specific bash aliases or the like is to
>create two files:
>
>~/.bash_profile is minimal and contains:
>
>if [ -f ~/.bashrc  ]; then. ~/bashrc; fi
>
>~/.bashrc has my local alias and a bash function gvim () as follows:
>
>gvim () { (env -u HOME -u VIM "/c/Program Files (x86)/vim/vim82/gvim.exe" "$*")& }

Self correction: To support multiple parameters properly I should use "$@" not
"@*", which confuses Gvim, so:

~/.bashrc has my local alias and a bash function gvim () as follows:

gvim () { (env -u HOME -u VIM "/c/Program Files (x86)/vim/vim82/gvim.exe" "$@")& }

>Another place on the Internet, I found advice to unset the HOME and
>VIM environment variables local to MinGW Bash as Windows GVIm 8.2 is
>started, but I converted a simple bash alias to bash function.  While
>the env command above would run GVim as a simple alias, the Git Bash
>shell blocks waiting for GVim to exit.  The bash function is needed
>so I can embed the env in a subshell with parentheses and push it to
>the background, while still passing parameters to the inner command
>line.  This bash function works, starting GVim and letting the shell
>continue.  I do notice that this Windows GVim shows up as a process
>when using the ps command at the Git Bash prompt.  I am not sure if
>anything funny happens, based on the order I close Git Bash and GVim.
>
>I am not sure if this is the best approach.  Another idea I saw on
>the Internet suggested using the bash disown built-in command, but I
>was getting syntax errors.  I tried debugging with set -x in Git Bash
>but extra commands I did not expect were being generated, probably
>due to Git integration.  I decided that this method is best, for now,
>but I am wondering if there are any gotchas lurking here.
>
>Thanks in advance for any advice.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200514220224.GC1444%40linux.site.
Reply | Threaded
Open this post in threaded view
|

Re: Starting Native Windows GVim 8.2 from MinGW Git Bash

Alessandro Antonello
Hi, Joganns.

Years ago, when I was using Windows, I had the same problem with a different environment. I was using Msys2 (https://www.msys2.org/) to have e little "Linux" environment in the Windows box. My solution was alike. I built a bash script that put the GVim process in background. I never had a problem with that. But I always kept my bash session opened. In that time I was working with both Windows and Mac OSX at the same time. Then I built a single environment that worked on both machines with some customizations. I had a set of bash scripts written to do the same thing on both systems. And that made me choose Msys2 instead of GitBash.

That configuration worked for years. Today I work only on Mac OSX, but I kept the set of bash scripts and configuration as much as I could since I can get back to work on Windows any time.

Regards,

Alessandro Antonello

Em sex, 15 de mai de 2020 03:10, <[hidden email]> escreveu:
On Thu, May 14, 2020 at 03:17:55PM -0400, [hidden email] wrote:
>I finally have a newish Windows 10 64-bit laptop for a course and,
>per instructions, have installed Git Bash that uses MinGW from:
>https://git-scm.com/downloads
>
>I also have a standard native Window build of GVIm 8.2 installed under:
>C:\Program File (x86)\Vim\vim82
>which I believe was the default for the standard installer.
>
>MinGW Git Bash ships with a built-in version of vim 8.2 as MinGW
>program, but does not include GVim.
>
>What I am looking to do is to start the native Windows version of
>GVim from a the Git Bash prompt.  Rather than change the path I hoped
>to use a simple bash alias with a full path to start Windows GVim
>8.2.  This works except that the bash prompt blocks as if Windows
>GVim is a console program and the shell is waiting to get control
>back of the console.  I am not entirely sure why the shell waits for
>Gvim to exit.  The same technique I am trying to was recommended for
>MSysGit Bash and Vim 7.4 by Albert Armea at:
>https://blog.albertarmea.com/post/115102365718/using-gvim-from-git-bash
>The best reason I can fathom is that I read elsewhere that MinGW is a
>more minimalist UNIX implementation than say Cygwin and does not
>implement fork() despite providing the header file.  Another
>possibility is that some trick integration set up in the bundle for
>Vim and GVim with Git is inadvertently fighting my attempt to use a
>Windows executable.
>
>Due to how Bash is invoked by the Git Bash bundle, the easiest way
>for me to configure user specific bash aliases or the like is to
>create two files:
>
>~/.bash_profile is minimal and contains:
>
>if [ -f ~/.bashrc  ]; then. ~/bashrc; fi
>
>~/.bashrc has my local alias and a bash function gvim () as follows:
>
>gvim () { (env -u HOME -u VIM "/c/Program Files (x86)/vim/vim82/gvim.exe" "$*")& }

Self correction: To support multiple parameters properly I should use "$@" not
"@*", which confuses Gvim, so:

~/.bashrc has my local alias and a bash function gvim () as follows:

gvim () { (env -u HOME -u VIM "/c/Program Files (x86)/vim/vim82/gvim.exe" "$@")& }

>Another place on the Internet, I found advice to unset the HOME and
>VIM environment variables local to MinGW Bash as Windows GVIm 8.2 is
>started, but I converted a simple bash alias to bash function.  While
>the env command above would run GVim as a simple alias, the Git Bash
>shell blocks waiting for GVim to exit.  The bash function is needed
>so I can embed the env in a subshell with parentheses and push it to
>the background, while still passing parameters to the inner command
>line.  This bash function works, starting GVim and letting the shell
>continue.  I do notice that this Windows GVim shows up as a process
>when using the ps command at the Git Bash prompt.  I am not sure if
>anything funny happens, based on the order I close Git Bash and GVim.
>
>I am not sure if this is the best approach.  Another idea I saw on
>the Internet suggested using the bash disown built-in command, but I
>was getting syntax errors.  I tried debugging with set -x in Git Bash
>but extra commands I did not expect were being generated, probably
>due to Git integration.  I decided that this method is best, for now,
>but I am wondering if there are any gotchas lurking here.
>
>Thanks in advance for any advice.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20200514220224.GC1444%40linux.site.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CA%2BJN8RKQ39%3D5UUjEaQt4a0YmRo6oKnGEWKGT5vca9%3DkTzii65Q%40mail.gmail.com.