iconoclast
iconoclast

Reputation: 22620

Why does Ctrl-Z on Windows Git bash shell fail?

I sometimes have to work in Windows, which often means using the Bash shell. If I am (for example) in vim (not gvim) with several files open, and I hit CtrlZ to briefly go back to the shell and do something before returning to vim, instead of suspending my vim process Git Bash creates a new DOS shell. This is the last thing I'd ever want. Googling turns up nothing useful (at this point in time - YMMV in my future). What is going on?

Upvotes: 14

Views: 6724

Answers (2)

Zero Distraction
Zero Distraction

Reputation: 1356

If I am (for example) in vim (not gvim) with several files open, and I hit ^Z to briefly go back to the shell and do something before returning to vim, instead of suspending my vim process Git Bash creates a new DOS shell.

If you execute other processes in git bash, CTRL-Z won't suspend them either. Vim works around that and, instead, creates a shell to achieve a similar result. Vim is a tool in windows that doesn't require bash, rather the windows command prompt will be necessarily installed in a windows machine. I assume this is a safe choice of the windows binary program.

This is the last thing I'd ever want. Googling turns up nothing useful (at this point in time - YMMV in my future). What is going on?

My guess here is that vim has the CTRL-Z map to creating a DOS shell. If you want to create a bash shell instead, you can type:

:!sh

And you will be executing in a bash shell.

Upvotes: 1

setrofim
setrofim

Reputation: 725

My guess that the reason for this is that Windows doesn't implement the POSIX suspend process API. I had the same issue and haven't found a general solution. But for specific common cases (such as gvim), a work around is to create a script somewhere in your PATH (e.g. /c/bin/gvim) along the lines of

   #!/bin/env bash
   /c/Program\ Files\ \(x86\)/Vim/vim73/gvim.exe $@ &

Upvotes: 1

Related Questions