If you want to code in Windows 11 but prefer the familiarity of a Unix environment.
- Install MSYS2
- Run MSYS2 inside Windows Terminal (or Preview) - optional
- Install oh-my-zsh
- Set zsh as your default MSYS2 shell
- Expose packages installed in MSYS2 to Windows
Install MSYS2
MSYS2 provides a minimal shell required to run autotools and other build systems which get the source for software from the Internet from different repositories, configure them and build them. The shell and core tools exist mainly to allow porting Unix programs to run natively on Windows (i.e. without requiring a POSIX emulation layer).
To install MSYS2, follow this guide in the official MSYS2 docs.
If you don't wanna use Mintty (the default terminal application in MSYS2), you may run MSYS2 in Windows Terminal instead.
- Open Windows Terminal settings. If you are using Windows Terminal Preview, this will open GUI. You need to click "Open JSON file" to open
settings.json
. - MSYS2 has provided Windows Terminal profiles here. Copy the profiles, and paste them in
settings.json
. If you have other profiles, be careful not to overwrite them. At the time of writing, here are the profiles:
"profiles": {
"list":
[
// ...
{
"guid": "{17da3cac-b318-431e-8a3e-7fcdefe6d114}",
"name": "MINGW64 / MSYS2",
"commandline": "C:/msys64/msys2_shell.cmd -defterm -here -no-start -mingw64",
"startingDirectory": "C:/msys64/home/%USERNAME%",
"icon": "C:/msys64/mingw64.ico",
"fontFace": "Lucida Console",
"fontSize": 9
},
{
"guid": "{2d51fdc4-a03b-4efe-81bc-722b7f6f3820}",
"name": "MINGW32 / MSYS2",
"commandline": "C:/msys64/msys2_shell.cmd -defterm -here -no-start -mingw32",
"startingDirectory": "C:/msys64/home/%USERNAME%",
"icon": "C:/msys64/mingw32.ico",
"fontFace": "Lucida Console",
"fontSize": 9
},
{
"guid": "{71160544-14d8-4194-af25-d05feeac7233}",
"name": "MSYS / MSYS2",
"commandline": "C:/msys64/msys2_shell.cmd -defterm -here -no-start -msys",
"startingDirectory": "C:/msys64/home/%USERNAME%",
"icon": "C:/msys64/msys2.ico",
"fontFace": "Lucida Console",
"fontSize": 9
},
// ...
]
}
- If you want MSYS2 to be the default profile Windows Terminal starts up when opened, set
MSYS / MSYS2
's guid (currently{71160544-14d8-4194-af25-d05feeac7233}
) as thedefaultProfile
.
Install oh-my-zsh
Install zsh
shell and curl
to download the oh-my-zsh
install script:
pacman -S zsh curl
Install oh-my-zsh
with:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
If you wanna customize your oh-my-zsh
set up, head over to the Using Oh My Zsh section of their official docs.
- Locate MSYS2 installation folder in windows. In my case, it's in
C:\msys64
. - Open
msys2_shell.cmd
. - Locate line
set "LOGINSHELL=bash"
and change it toset "LOGINSHELL=zsh"
Now every time MSYS2 is opened, it will load zsh
as the default shell.
- Open "Run" by pressing
Windows + R
, and type insystempropertiesadvanced
. - Click on the "Environment Variables" button.
- In the "System Variables" section, scroll down and double-click on the "Path" variable.
4a. If you’re on Windows 7/8, add the text
C:\msys64\usr\bin;C:\msys64\usr\local\bin;
to the beginning of the variable value. 4b. If you’re on Windows 10+, add theC:\msys64\usr\bin
andC:\msys64\usr\local\bin
folders to the list.
To test if this is working, open a Windows Command Prompt and paste the following:
grep --help
If it shows you the man page(s) of grep
, you're good to go!
The MSYS2 team has provided a comparison between MSYS2 and other Projects. You can check that out to see if it aligns with you use case.