3

From a Windows 7 Command Prompt:

ConEmu.exe /cmd "C:\Program Files\Git\bin\sh.exe" --login -i && exit

opens ConEmu (or a new tab therein) logged into Git Bash for the current directory, and (very quickly) exits the Command Prompt window, all good.

From gVim:

:silent !ConEmu.exe /cmd "C:\Program Files\Git\bin\sh.exe" --login -i
  1. if ConEmu was already running, opens a new tab logged into Git Bash for the buffer's directory, and exits the intermediary Command Prompt window, and returns me to my current buffer, all good.
  2. if ConEmu was not running, it's opened logged into Git Bash as above, but the intermediary Command Prompt window is left up in a seized state, requiring me to terminate it to unfreeze gVim. (Appending $$ exit to the above gVim command doesn't help.)

The Question: How can I fix the 2nd gVim case, such that the Command Prompt window called by gVim closes automatically as in the 1st gVim case?


Supplementary gVim info (responding to @Maximus):

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 29 2014 07:03:32)

Sysinternals' Process Monitor Filter'd for Operation Process Start finds that this heirarchy of Commands, all labelled "(ConEmu.exe)", are triggered by :!ConEmu:

  1. "C:\Program Files\vim\vim74\vimrun" C:\windows\system32\cmd.exe /c
  2. C:\windows\system32\cmd.exe /c C:\windows\system32\cmd.exe /c
  3. C:\windows\system32\cmd.exe /c

vimrun.exe is not in %PATH%.


Alternative attempt from gVim, using win32-!start:

Don Reba at Vim Wikia explains:

if you enter a command like :!calc (to run calc.exe for the Windows calculator), Vim will open a shell window, then launch a new calc window from that shell. When calc is closed, the prompt Hit any key to close this window... appears, and Vim is frozen until a key is pressed. But Calculator is a GUI program so it runs in a new process, in a new window. So, if you want to asynchronously run a GUI program like Calculator, you can simply enter :!start calc

So I tried:

!start ConEmu.exe /cmd "C:\Program Files\Git\bin\sh.exe" --login -i && exit

- which doesn't seize gVim and opens a new ConEmu tab in Git at gVim's working directory, but fails to login, reporting sh.exe": &&: No such file or directory, followed by:

Command to be executed: "C:\Program Files\Git\bin\sh.exe" --login -i && exit
ConEmuC: Root process was alive less than 10 sec, ExitCode=127.
Press Enter or Esc to close console...

  • 1. Question unclear. 2. sh.exe": &&: No such file or directory. – Maximus Nov 14 '14 at 21:24
  • @Maximus, I've attempted to clarify the question (on the last line). I can't make sense of your 2nd point. – JosephHarriott Nov 15 '14 at 14:39
  • When I run :silent !ConEmu.exe from gVim there is no "command prompt window", only ConEmu. – Maximus Nov 15 '14 at 18:28
  • @Maximus, I've just tried that on my ancient N130, and (maybe because it's so slow) there is, for about one second, a Command Prompt window. Run just :!ConEmu, and you'll see that CP window stating "Hit any key to close this window...", which is necessary to now unfreeze gVim. – JosephHarriott Nov 15 '14 at 18:41
  • gVim version. Show screenshot. Run ProcessMonitor and look for Process Start events. What is started? – Maximus Nov 15 '14 at 20:15

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.