-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using MSYS2 in Windows Terminal #1684
Comments
Looks like you asked there too: microsoft/terminal#1669 Did you get it working? |
This seems to work:
where
May be we need to adjust the guid with |
Instead of a separate script you can just use: |
@patstew, thanks for the suggestions, but it is not a separate script but the same Thanks. |
I was just pointing out you don't need any .cmd at all. |
Just noting here that one can define CHERE_INVOKING=1 and the profile will then honor the "startingDirectory" parameter. Like this:
|
OK, I tried this that seems to work:
and noticed that has:
In MInTTY, instead it is See also this #2953. |
Let me know if we have to reclose this |
I just tried this too, and terminal things do not work, even if I manually set E.g. tmux says:
colors in vim don't work, etc.. |
Colors are all broken for me too. |
@restia666ashdoll, also this works
but you cannot set environment variables. For example, what do you use to start a MSYS2/MinGW64 shell? This works for me:
and similar for MSYS2, MSYS2/MinGW32 shells. |
@restia666ashdoll try forward slashes. While these methods may work for people for git, we still need an actual fix for the terminal to work correctly as a terminal. |
If you install them with
|
My config (with windows PATH included --> vscode and other stuff can work), notice {
"acrylicOpacity": 0.75,
"closeOnExit": true,
"colorScheme": "Campbell",
"commandline": "cmd.exe /c \"set MSYSTEM=MINGW64&& set MSYS=winsymlinks:nativestrict&& set MSYS2_PATH_TYPE=inherit&& C:/msys64/usr/bin/bash.exe --login\"",
"cursorColor": "#FFFFFF",
"cursorShape": "bar",
"fontFace": "Consolas",
"fontSize": 10,
"guid": "{1597a4d0-b666-4b1f-a8d3-79af62638679}",
"historySize": 9001,
"icon": "C:\\msys64\\msys2.ico",
"name": "MSYS2",
"padding": "0, 0, 0, 0",
"snapOnInput": true,
"startingDirectory": "%USERPROFILE%",
"useAcrylic": true
} MSYS2 configuration thanks to this great article |
Sadly, this doesn't give me a terminal with 256 colors. {
"guid": "{75529e5d-bde6-4848-85f4-d73c3838a5f5}",
"name": "MinGW 64",
"commandline": "cmd.exe /c set MSYSTEM=MINGW64 && c:/msys64/usr/bin/bash --login -i",
"cursorColor": "#FFFFFF",
"cursorShape": "bar",
"hidden": false,
"icon": "C:\\msys64\\msys2.ico",
"fontFace": "Cascadia Code",
"startingDirectory": "%USERPROFILE%"
}, I used the test script here I think it is related to this one |
Those're two different tests. The pipe-to-bash test from @machsix 's link is generating blocks use "Set Background Colour to x" (SGR 48) for x in the range 1-255 (i.e. 256-colour palette). The one-liner used by @restia666ashdoll is iterating through the 9 terminal styles, for each of the eight foreground colours and eight background colours (i.e. 8/16 colour palette, since usually 'bold' in that palette means a second set of 8 colours, traditionally brighter versions of the first 8). @restia666ashdoll's script for easy cut-and-paste. for x in {0..8}; do for i in {30..37}; do for a in {40..47}; do echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m "; done; echo; done; done; echo "" 256-colour support is definitely an issue about MSYS2 or bash or cygwin interacting with ConPTY, since I can do:
and see the same result as @machsix, but outputting the same file (256col.ans) under PowerShell Core in MS Terminal or directly, (or MSYS in MinTTY) shows the intended result. The same problem shows up if I run PowerShell Core directly (rather than inside MS Terminal) and then start MSYS in-place with
Given that the foreground text on 30, 31, 32, and 33 have come out differently, but all used the same command ( |
Another good test to show it's something about cygwin and Windows ConHost is https://github.com/Maximus5/ConEmu/blob/master/Release/ConEmu/Addons/AnsiColors256.ans. In the faulty case, you see a bunch of And looking again at microsoft/terminal#2837, that's almost certainly the issue. https://conemu.github.io/en/CygwinAnsi.html is a good description of the underlying issue. |
To bring it back to MSYS, It's not obvious what goes wrong, since the first row of that table is the same as the values for 30-37, then again with bold added, so something else must be mangling the sequences. It's also possible the parsing itself ( |
Trying to track this down, it seems that there's a value I'm definitely getting Ah! The msys-runtime package is still on Cygwin 3.0.7, and the change above for 24-bit colour support in Windows landed in Cygwin 3.1, along with Pseudo Console support which (I think) removes the need for the So for 24-bit colour support in Windows Terminal, we need to upgrade msys-runtime, which I think should be a separate bug report from this one. As far as the original question, I'm using the simple solution from the other ticket
|
Any changes there? |
As @TBBle said, we need someone to update the msys2 runtime to the latest cygwin version. Any volunteers? |
The new conpty interface in cygwin is not complete yet. New issues pop up everyday as well as new patches. |
All the terminal stuff is still kind of buggy. I have been using mostly powershell 7, with the new terminal and over ssh, and I see all kinds of weird issues with things like the native vim in various configurations. Sometimes it works perfectly, other times it misaligns everything and puts stars around words, other times it takes up only half the terminal, etc. etc.. I just end up using whichever version of vim or neovim works in that configuration. I'd love to be able to use the new terminal with msys2, and do things like start an msys2 shell from a native sshd powershell session etc.. |
Perhaps the cygwin terminal stuff may not be perfect, but better than nothing for a lot of people. @Alexpux how do you feel about this? Would it helped if we made a PR (and tested it thoroughly of course) to merge the latest cygwin runtime? |
What's the difference between |
From
|
See this line in my profiles.json file |
Thanks, but it's msys2.icon, what I want is mingw64 icon, which has a blue background. |
You can get the icons here: |
I've updated my sshd setup script to support Cygwin, due to a request, as well and to be more automated, it sets up keys and host aliases automatically now. MSYS2 and Cygwin sshds can be used at the same time, along with the Windows native sshd. This gives you full terminal support, including for tmux, and remote support (obviously) the only limitation is that running GUI apps is not possible. https://github.com/rkitover/windows-alt-sshd-msys2 |
@rkitover Thank you, it works! |
Just as a note: I think that no amount of "enabling the runtime to use the pseudoconsole API" is going to help tmux determine that its parent device is a tty. Pseudoconsole support changes what happens when a pty is allocated, which is not the thing that tmux is failing to do. If we consider tmux as a set of steps,
It's failing on 2.a.; enable_pcon would only impact 3. |
Does anyone know how to set a right click context menu to do:
I have been using this reg file to do such thing, but I have no idea how to change to terminal ..
|
This works like charm with system path recognized {
"commandline": "C:\\tools\\msys64\\msys2_shell.cmd -defterm -here -no-start -mingw64 -shell bash -use-full-path",
"experimental.retroTerminalEffect": false,
"guid": "{a69dbdaf-3219-4965-a5a7-2210313f9581}",
"hidden": false,
"icon": "C:\\tools\\msys64\\msys2.ico",
"name": "MSYS2",
"opacity": 85,
"startingDirectory": null,
"tabTitle": "MSYS2"
} |
That worked @CGQAQ !! Thanks a lot! |
Hi there! Here are my configurations: {
"commandline": "C:\\msys64\\msys2_shell.cmd -defterm -here -no-start -ucrt64 -shell bash -use-full-path",
"cursorShape": "underscore",
"elevate": false,
"experimental.retroTerminalEffect": false,
"guid": "{fe36c14f-2b13-4109-8e9a-5414c547bb40}",
"hidden": false,
"icon": "C:\\msys64\\msys2.ico",
"name": "MSYS2 UCRT64",
"startingDirectory": "D:\\Dev",
"tabTitle": "MSYS2 UCRT64"
} But the bash's character ($) has changed to a (#) now. I would like the dollar sign back. Any ideas? |
Probably the Windows Terminal is running as administrator. |
msys2 is working in Windows Terminal, right? Can this issue be closed now? There is a documentation about how to use msys2 in Windows Terminal here https://www.msys2.org/docs/terminals/#windows-terminal |
I would be a lot better if the official documentation didn't use a .cmd batch script and instead just invoked what it needs directly for each environment. Because of this bat file approach, closing MSYS2 terminals gives a E: As commented here microsoft/terminal#14663 |
@ipaqmaster, with WT 1.18 you need just this:
or this:
|
I was looking for somewhere to set variables right in WT. Felt strange that there was no facility to do so. Glad it's a feature now. |
Even with "environment" key set and "commandline" key with value of "bash --login", MSYS2 still shows "Press Ctrl-D to close or Enter to restart" on {
"commandline": "C:/tools/msys64/usr/bin/bash --login",
"environment":
{
"CHERE_INVOKING": "1",
"MSYS": "winsymlinks:nativestrict",
"MSYSTEM": "UCRT64"
},
"font":
{
"face": "Lucida Console"
},
"guid": "{71160544-14d8-4194-af25-d05feeac7233}",
"icon": "C:\\tools\\msys64\\ucrt64.ico",
"name": "UCRT64 / MSYS2",
"startingDirectory": "C:/tools/msys64/home/%USERNAME%"
}, |
NOT here
Maybe you have something different elsewhere.. |
Windows Terminal version: 1.17.11461.0 probably does this too, but closes the tab instantly after that. Looks like version 1.18.1462.0 changed the default (Automatic) behaviour. {
+ "closeOnExit": "always",
"commandline": "C:/tools/msys64/usr/bin/bash --login",
"environment":
{
... ... or maybe use + "closeOnExit": "graceful", The GUI way: I see @angelog0 confirms my suggestion (Mid-air collision detected:) |
This is my MSYS2 configuration if anyone is interested. Windows Terminal
VS Codesettings.json
Jetbrains IDEGo to Setting => Tools => Terminal Right click open MSYS2 MINGW64 (Context menu)Use BluePointLilac ContextMenuManager add new item in Background category
|
Does anyone know how to persist the zsh command history? {
"guid": "{55355a23-abac-48c2-b092-70c8cfc95684}",
"hidden": false,
"name": "zsh",
"icon": "C:\\Users\\alshdavid\\.local\\msys64\\msys2.ico",
"closeOnExit": "always",
"commandline": "C:\\Users\\alshdavid\\.local\\msys64\\msys2_shell.cmd -defterm -here -no-start -mingw64 -shell zsh",
"startingDirectory": "C:/Users/%USERNAME%",
"environment": {
"MSYS": "winsymlinks:nativestrict",
"CHERE_INVOKING": "1",
"MSYSTEM": "MINGW64"
}
}, For bash, adding If I quit the terminal with |
I guess that you want to enable the |
I raised an issue with the Windows terminal team here: microsoft/terminal#17856 (comment) |
And they punted it back here, stating that the difference between what zsh expects when its window is closed (probably a SIGHUP) and what it receives right now lives in the cygwin runtime (i.e. msys2-runtime for msys2 packages). I had a quick look and per msys2-runtime source it looks like it should be generating a SIGHUP as expected, but even 22 years ago, SIGHUP didn't seem to be reliable in cygwin. I am also just blindly assuming that zsh would save its history on SIGHUP. I had a quick look at the zsh source, but didn't work through the signal handling code to confirm that. But I am fairly sure bash saves history on SIGHUP, and since we need a "write-history-after-every-command" workaround for it as well, I am assuming the problem is not on the zsh side. |
@TBBle You may want to ask the Cygwin mailing list, they may know more about this. |
Has someone tried to use MSYS2 and friends (MinGW32/64) in the new Windows terminal? What would it be the MSYS2-profile?
Thanks...
The text was updated successfully, but these errors were encountered: