Windows – Git for Windows: Run vim in background without ampersand (&)

gvimmsysgitterminalvimwindows

On my Windows machine, running gVim appears to tie up the git for windows shell, whereas if I run from the command prompt, this is not the case.

How might I be able to run gVim (or any other program, really) without tying up the shell and having to add an '&' to the end of each command?

Any help on this issue would be much appreciated.

Git Bash:

$ gvim hello.txt
[Terminal is now blocked]
[Hit ctrl+c or close gvim, terminal takes input]
$ 

Windows Command Prompt:

> gvim hello.txt
> [ Can still access cursor and execute commands]

Best Answer

The answer I've found that works most like it does on my Linux box is to set an alias in your .bashrc:

alias gvim='start gvim'

This is still not the most ideal fix, but it feels a little cleaner to me than creating a function. Also it does not print the process ID line (example: "[1] 6840") when you run it or when you close the external window.

This still has the problem from the function fix that it only works for things you create an alias for. So notepad for example still blocks your bash unless you create a start notepad alias. Based on this post at the MSDN blog it looks like Windows executables have a flag that tells the console whether or not it is a GUI application, but from what I can see, git bash does not differentiate based on that flag in the same way that cmd.exe does. If you could attach something to every command entered that would check the .exe for the GUI flag, and prepend start based on your result, then you'd be good to go.

Related Question