Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 428
iconoclast Avatar asked Sep 10 '12 16:09

iconoclast


People also ask

Why does Ctrl V not work in Git bash?

Make sure the "Quick Edit Mode" option is checked. If an "Experimental" tab shows up, select it and then make sure the top "Enable experimental console" and the "Enable new Ctrl key shortcuts" options are both checked. Click 'OK' to save. Now you can use Ctrl+V to paste.


2 Answers

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.

like image 92
Zero Distraction Avatar answered Oct 14 '22 21:10

Zero Distraction


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 $@ &
like image 31
setrofim Avatar answered Oct 14 '22 20:10

setrofim