Sent this to Ray he told me they will maybe integrate such functionality when msys2 has an installer package ready.
Anyway just sharing it here for anyone who needs a handy 'Start msys2 command prompt' in the Windows context menu when right-clicking any directory, this will start msys2 in the said directory =)
How to use: apply patch, run msys2 normally, double click the newly created msys2_shell.reg
--- msys2_shell.bat.a 2014-02-22 21:22:09.251183600 +0100+++ msys2_shell.bat.b 2014-03-13 18:12:42.821821100 +0100@@ -28,14 +28,22 @@
if "x%1" == "x-consolez" set MSYSCON=console.exe
if "x%1" == "x-mintty" set MSYSCON=mintty.exe
+if "x%1" == "x-customdir" goto startminttycustomdir
if "x%MSYSCON%" == "xmintty.exe" goto startmintty
if "x%MSYSCON%" == "xconsole.exe" goto startconsolez
:startmintty
if NOT EXIST %WD%mintty.exe goto startsh
+if NOT EXIST %~dp0\msys2_shell.reg goto registermintty
start %WD%mintty -i /msys.ico -
exit
+:startminttycustomdir+if NOT EXIST %WD%mintty.exe goto startsh+rem https://code.google.com/p/mintty/wiki/Tips#Starting_in_a_particular_directory+start %WD%mintty -i /msys.ico /bin/env CHERE_INVOKING=1 /bin/bash -l+exit+
:startconsolez
cd %WD%..\lib\ConsoleZ
start console -t "MSys2"
@@ -45,4 +53,17 @@
start %WD%sh --login -i
exit
+:registermintty+set WR=%~dp0\msys2_shell.reg+set DIR=%~dp0+set DIR=%DIR:\=\\%+echo Windows Registry Editor Version 5.00>%WR%+echo.> NUL 2>&1>>%WR%+echo [HKEY_CLASSES_ROOT\Folder\shell\Command_Prompt_MSYS2]>>%WR%+echo @="Command Prompt Msys2">>%WR%+echo.> NUL 2>&1>>%WR%+echo [HKEY_CLASSES_ROOT\Folder\shell\Command_Prompt_MSYS2\command]>>%WR%+echo @="cmd.exe /a /k cd /d \"%%l\" && %DIR%msys2_shell.bat -customdir">>%WR%+goto startmintty+
:EOF
Nice suggestion, I've been using this for several months now. Too bad that nothing like this has been integrated into MSYS2 yet, although meanwhile an installer is already available.
I adapted your approach to the most recent MSYS2 release, since several modifications have taken place since then. The main starting code is now inside the "start_shell.cmd" script, so I would suggest the below patch.
It introduces a new -here argument (as proposed here) and should not introduce any unwanted side-effects. I think integrating this patch would at least be a first step to avoid having to manually edit the batch scripts, especially since they will be overwritten with the next update.
@ph4nt0m I suggest to create a PR on github with your patch. All development happens there and proposing your patch has a good chance of being integrated. If you do so, ping Karlson2k has he did most of the re-work of the shell scripts so he might have input on your patch.
There is little chance it will get integrated if it stays here.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sent this to Ray he told me they will maybe integrate such functionality when msys2 has an installer package ready.
Anyway just sharing it here for anyone who needs a handy 'Start msys2 command prompt' in the Windows context menu when right-clicking any directory, this will start msys2 in the said directory =)
How to use: apply patch, run msys2 normally, double click the newly created msys2_shell.reg
https://sourceforge.net/p/msys2/tickets/30/attachment/msys2_register_context_menu.patch
Last edit: class101 2014-03-13
Nice suggestion, I've been using this for several months now. Too bad that nothing like this has been integrated into MSYS2 yet, although meanwhile an installer is already available.
I adapted your approach to the most recent MSYS2 release, since several modifications have taken place since then. The main starting code is now inside the "start_shell.cmd" script, so I would suggest the below patch.
It introduces a new -here argument (as proposed here) and should not introduce any unwanted side-effects. I think integrating this patch would at least be a first step to avoid having to manually edit the batch scripts, especially since they will be overwritten with the next update.
@ph4nt0m I suggest to create a PR on github with your patch. All development happens there and proposing your patch has a good chance of being integrated. If you do so, ping
Karlson2k
has he did most of the re-work of the shell scripts so he might have input on your patch.There is little chance it will get integrated if it stays here.