Executando verificação de segurança...
5

Step-by-Step Guide to Install and Configure Zsh and Oh My Zsh on Windows Without WSL

Zsh is a powerful and customizable shell that can be used as an alternative to Bash on Unix systems. In this guide, we’ll show you how to install and configure Zsh on Windows using MSYS2, which is a free software distribution for Windows that provides a Unix-like environment.

Requirements:

  • Windows Terminal (optional)
  • MSYS2 (required)
  • Git (required)

Step 1 – Download MSYS2:

MSYS2 is required to run Zsh. Download the appropriate version for your system architecture at https://www.msys2.org/.

Step 2 – Open MSYS2:

After installation, open the MSYS2 mingw64 terminal.

Step 3 – Update Pacman::

Run the following command to update Pacman:
pacman -Syu

Step 4 – Install the Zsh Package::

Run the following command to install Zsh:
pacman -S zsh

After installation, a configuration screen may appear with options to choose from. Since you probably don’t have a .zshrc file yet, do not make any changes here—just exit the screen.

Step 5 – Install Git::

Run the following command to install Git so that MSYS2 can recognize Git commands:
pacman -S git

Step 6 – Install Oh My Zsh:

Run the following command to install Oh My Zsh:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Oh My Zsh will automatically create the .zshrc configuration file for you.

Step 7 – Install Zsh Autosuggestions:

Run the following command to install Zsh Autosuggestions:
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

Step 8 – Install Zsh Syntax Highlighting:

Run the following command to install Zsh Syntax Highlighting:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Step 9 – Configure Plugins in .zshrc:

Open the .zshrc file with:
nano ~/.zshrc

Change the plugins line to:
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
Save and close the file.

To start using Zsh, simply type zsh in the MSYS2 terminal.

Important Notes!!

NOTE: Make sure the folders C:/[MSYS2 installation path]/usr/bin and C:/[MSYS2 installation path]/usr/local/bin are in your system environment PATH.

In your .zshrc file, add an alias for npm and npx and include the Node.js path:

export PATH=$PATH:"/c/[Caminho do node js]/nodejs"
alias npm='npm.cmd'
alias npx='npx.cmd'

The Oh My Zsh folder will be located at:
C:/[MSYS2 installation path]/home/[YOUR USER]/.oh-my-zsh

The Zsh executable will be located at:
C:/[MSYS2 installation path]/usr/bin

NOTE: If Zsh does not recognize commands like npx (as happened in my case), even with the alias, reinstall npx globally.

Using Windows Terminal to Run Zsh Directly (Optional):

  • Open Windows Terminal and go to Settings
  • Add a new empty profile
  • In the command line option, enter the Zsh executable: C:/[MSYS2 installation path]/usr/bin/zsh.exe

Now, you can select this Zsh profile in Windows Terminal, and it will open directly in Zsh.

Carregando publicação patrocinada...
1
1
1
0
0
0