Using Cygwin in 2023
Overview
In one of my customer project I have to use a Windows 11 system. In 2023, it should be not a problem as a Linux fan to work on a Windows system, because I could install WSL2 and the story would end on this point. Because of reasons, it is not allowed and not possible to install WSL2 on my system, so I fall back to Cygwin.
The default shell on Cygwin is a Bash, but I like to use ZSH in combination with the framework oh-my-zsh and the theme Starship. Of course, Cygwin is not a 100% replacement for WSL2, but it simplifies many things, that I like to do in a shell.
In the next sections, I like to show you how to install oh-my-zsh on Cygwin, other goodies like installing a package manager for Cygwin, and which limits I found during using Cygwin.
Let's start with the installation of Cygwin.
Install Cygwin
Go to the homepage of Cygwin and download setup-x86_64.exe
. If you don't have admin rights on your system, you have to use the powershell or CMD to execute the exe-file with a special flag:
1setup-x86_64.exe --no-admin
On the package dialog, choose zsh
, git
, unzip
, curl
and wget
for installing and finish the Cygwin installation.
Set ZSH as default shell
As I said before, the default shell on Cygwin is Bash, so you have to set ZSH as the new default shell.
The easiest way is, to set your SHELL
user environment variable. Search for Edit Environment variables for your account to bring up the environment variables window, create a new variable named SHELL
and give it the value /usr/bin/zsh/
.
Install oh-my-zsh
With the above preparations, installing oh-my-zsh on Cygwin is as easy as on a normal Linux environment. Call
1sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Install Theme Starship
Normally, the installation works like in a normal Linux environment. Run
1curl -sS https://starship.rs/install.sh | sh
and add the following line to the end of your .zshr
file:
1eval "$(starship init zsh)"
If the installation script failed, edit it and remove the if condition that let fails the installation.
Install Package Manager apt-cyg
If you don't want to call the setup.exe everytime, when you want to install a new package, you can install a package manager in Cygwin, called apt-cyg
1wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg
2install apt-cyg /bin
After the installation you can install new package with
1apt-cyg install <package name>
My found limits
You can't use the current Azure cli on Cygwin, because a Python package for crypto needs Rust and Rust is currently not supported in Cygwin out-of-the-box. Therefore, I use Azure CLI in the Powershell