Skip to content

Instantly share code, notes, and snippets.

@evanwill
Last active October 24, 2024 17:27
Show Gist options
  • Save evanwill/0207876c3243bbb6863e65ec5dc3f058 to your computer and use it in GitHub Desktop.
Save evanwill/0207876c3243bbb6863e65ec5dc3f058 to your computer and use it in GitHub Desktop.
how to add more utilities to git bash for windows, wget, make

How to add more to Git Bash on Windows

Git for Windows comes bundled with the "Git Bash" terminal which is incredibly handy for unix-like commands on a windows machine. It is missing a few standard linux utilities, but it is easy to add ones that have a windows binary available.

The basic idea is that C:\Program Files\Git\mingw64\ is your / directory according to Git Bash (note: depending on how you installed it, the directory might be different. from the start menu, right click on the Git Bash icon and open file location. It might be something like C:\Users\name\AppData\Local\Programs\Git, the mingw64 in this directory is your root. Find it by using pwd -W). If you go to that directory, you will find the typical linux root folder structure (bin, etc, lib and so on).

If you are missing a utility, such as wget, track down a binary for windows and copy the files to the corresponding directories. Sometimes the windows binary have funny prefixes, so you should rename the .exe file to the standard name. Since bin is on the PATH, it will be automatically available to Git Bash.

Note: Many interactive utilities, such as python, ipython or nano, will not display properly with Git Bash's mintty terminal. Try invoking them with winpty instead, for example winpty ipython will work nicely. The Git-for-Windows team is focused on supporting Git, not a full UNIX shell environment. If you are interested in more complete package with build tools, check my notes on Cygwin or Cmder--or install Windows Subsystem for Linux or WSL2.

Here are some utilities to add:

Wget

  • Download the lastest wget binary for windows from eternallybored (they are available as a zip with documentation, or just an exe)
  • If you downloaded the zip, extract all (if windows built in zip utility gives an error, use 7-zip).
  • Rename the file wget64.exe to wget.exe if necessary.
  • Move wget.exe to your Git\mingw64\bin\.

Note: I have noticed some bugs when using Wget on Git Bash to create WARC files. For more complex use of Wget, consider Cygwin instead.

Hugo

Hugo static site generator can be downloaded as a binary and does not have a installer. Dropping it into your bin easily adds it to your Git Bash path. Grab the Windows 64-bit version from the releases page. Unzip the download, then copy hugo.exe into your Git\mingw64\bin directory.

Xpdf

Xpdf is a handy utility for manipulating PDF files.

  • Download the windows version "Xpdf tools".
  • Extract zip.
  • Copy the contents of xpdf-tools-win-4.00\bin64\ into your Git\mingw64\bin\.
  • Check the docs to get started with tools such as pdftotext and pdftopng.

ExifTool

  • Download the "stand-alone Windows Executable" from the ExifTool page (this will be a .zip file e.g. "exiftool-11.99.zip").
  • Unzip the downloaded file.
  • Inside you will find a file named exiftool(-k).exe. Rename it to exiftool.exe.
  • Move exiftool.exe to your Git\mingw64\bin\.

Other possibilities

Most utilities that provide binary releases for Windows can be added to GitBash following the same pattern. Here are some more handy examples:

make

Keep in mind you can easy add make, but it doesn't come packaged with all the standard UNIX build toolchain--so you will have to ensure those are installed and on your PATH, or you will encounter endless error messages.

  • Go to ezwinports.
  • Download make-4.1-2-without-guile-w32-bin.zip (get the version without guile).
  • Extract zip.
  • Copy the contents to your Git\mingw64\ merging the folders, but do NOT overwrite/replace any existing files.

Nano

As of 2018, recent versions of Git Bash include Nano, so this is unnecessary! Just be sure to choose Nano as your default editor when installing Git for Windows.

  • Download the Nano binary from Nano win32-support page. You just need the .exe file, which is named nano-git-0d9a7347243.exe (as of this writing).
  • Rename the file to nano.exe, and copy to the mingw64\bin directory.
  • This version of Nano will not work with Git Bash alone, but can be invoked using winpty, for example, winpty nano test.txt.
@e-fb
Copy link

e-fb commented Nov 1, 2022

How about man command in Git Bash terminal? Have you tried adding man to your Win laptop? Please share if you have done. Thanks.

@ch1cano
Copy link

ch1cano commented Jul 8, 2023

Thanks a lot dude!

@Ethkuil
Copy link

Ethkuil commented Jan 6, 2024

How about man command in Git Bash terminal? Have you tried adding man to your Win laptop? Please share if you have done. Thanks.

My solution:

  1. tldr, --help. tldr
  2. curl cheat.sh/command
  3. Man Pages Archive - manned.org, wsl man <command>

So I found the man command isn't so necessary for me.

@Ethkuil
Copy link

Ethkuil commented Jan 6, 2024

Add an util: tree. The tree.com of Windows is terrible for me.

winget add MSYS2.MSYS2
# now we have pacman

pacman -S tree

@derzhavets-emg
Copy link

It worked, thank you!

@masterivanic
Copy link

Thanks for this tools amazing 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment