Setting up your Git Bash/ZSH terminals on Windows

Leonardo Mauro P. Moraes
3 min readMar 15, 2023

--

Command-line tool
Photo by Gabriel Heinzer on Unsplash

Git Bash and ZSH are command-line interfaces that allow users to interact with their operating system using text commands. Although Windows comes with its own command prompt, many developers prefer to use Git Bash or ZSH because they offer a more powerful set of features. Turning into powerful tools for developers.

This tutorial provides a comprehensive guide with essential steps and tips for implementing a great terminal for development on Windows machines.

Setup Git Bash

To setup Git Bash on Windows, follow these steps:

  1. Download the Git for Windows installer from the official website.
  2. Run the installer and select the desired components. Make sure the “Git Bash” option is selected.
  3. Follow the rest of the installer prompts to complete the installation.

Once Git Bash is installed, you can access it by right-clicking in a folder and selecting “Git Bash Here” from the context menu. This will open a Git Bash terminal window in that folder.

Setup ZSH

Git Bash / ZSH on Windows by Walter Teng.

To setup ZSH on Git Bash, follow these steps:

1. Download the latest ZSH package from the MSYS2 package repository. The file will be named something like “zsh-5.8–5-x86_64.pkg.tar.zst.

2. Install an extractor that can open TAR and ZST archives such as 7-Zip and facebook/zstd (named something like “zstd-v1.5.2-win64.zip”). First, use zstd to extract the TAR file. Later, use 7-Zip to extract the files into the Git Bash directory.

# Open Git Bash
# Navigate to zstd file
$ cd ~/../zstd-v1.5.4-win64

# Decompress the .zst file
$ ./zstd --decompress ~/Downloads/zsh-5.8-5-x86_64.pkg.tar.zst

# The TAR file will be created in the ~/Downloads/ directory
$ ls ~/Downloads/ | grep .tar

3. Extract the archive’s file using the 7-Zip (which should include etc and usr folders) into your Git Bash installation directory. This directory is usually located at “C:\\Program Files\\Git”. If asked, merge the contents of the folder (no files should be overwritten).

4. Open Git Bah and test the ZSH.

# Testing ZSH
$ zsh

5. Configure ZSH as default command-line shell.

# Create/edit the ~/.bashrc file
$ notepad ~/.bashrc

# Add the following content
if [ -t 1 ]; then
exec zsh
fi

# Save the file and close the Git Bash

Once ZSH is installed and set as the default shell, you can access it by opening the Git Bash. Now, your Git Bash will open a ZSH terminal.

Setup oh-my-zsh (optional)

oh-my-zsh is a popular open-source framework for managing ZSH terminal. It includes a large number of plugins and themes, as well as a set of default configurations that can help you get started with ZSH. Using oh-my-zsh can help simplify and streamline your development, making it easier and more powerful than ever.

1. Installing oh-my-zsh, execute the following command on Git Bash.

# Install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Additional packages

Conclusion

In summary, Git Bash and ZSH are powerful command-line interfaces that offer a more flexible and feature-rich alternative to the Windows command prompt. By following the steps outlined in this tutorial, you can easily set up Git Bash and ZSH on your Windows machine and start using them for your development work.

Reference

--

--

Leonardo Mauro P. Moraes

Is a Machine Learning Engineer and Team Leader… working with data-related products