Migrating Pacman to Git for Windows and Installing zsh, tmux, etc.
Introduction
I previously installed the Scoop package manager on my computer, but since Windows can't install certain applications, and I don't want to install WSL, I found out that I can create a Unix-like environment and command-line interface using tools like Cygwin or MSYS2. Notably, Git for Windows comes pre-packaged with a minimal MSYS2 environment called Git BASH, so I decided to give it a try.
Installing Git for Windows
Download Link: https://gitforwindows.org/
(If you already have this essential software installed, you can skip this step.)
Preparing Binary Files
Download
You can find pacman
in the MSYS2 package repository: https://packages.msys2.org/package/pacman?repo=msys&variant=x86_64
Download the corresponding pkg.tar.zst
file and all Dependencies
corresponding pkg.tar.zst
files to the Git installation directory. The core files generally include:pacman
, gnupg
, msys2-keyring
, pacman-mirrors
, zstd
, etc.
Extract
Since Scoop is already installed, you can use Scoop to install zstd
. If not, please visit the official website.
scoop install zstd
Extract the files using:
zstd -d *.zst
for file in *.tar; do
tar xvf "$file" -C /
done
Initialization
pacman-key --init && pacman-key --populate msys2
Usage
pacman -Sy
tmux
pacman -S tmux --overwrite "*"
zsh-related
Install zsh
:
pacman -S zsh --overwrite "*"
Set zsh
as the default shell:
vim ~/.bashrc
Add the following:
# Launch Zsh
if [ -t 1 ]; then
exec zsh
fi
Install Oh My Zsh:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Download plugins like Zsh-Autosuggestions, Zsh-Syntax-Highlighting, etc.:
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
Configure .zshrc
:
vim ~/.zshrc
Add or modify:
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
Then, apply the changes:
source .zshrc
Additional Notes
- Installing MSYS2 directly and using
pacman
to install Git can completely skip these steps. If you encounter the error
failed to synchronize all databases (invalid or corrupted database (PGP signature))
orerror: mingw32: signature from "Christoph Reiter (MSYS2 master key) <[email protected]>" is unknown trust
, ensure that all dependencies are fully downloaded and extracted to the correct location. Alternatively, you can try:rm -r /etc/pacman.d/gnupg/
Then reinitialize.