# Unix Utilities for
Emacs on MS Windows

On this page:

- Unix Utilities for Emacs on MS Windows
- - Most are Command Line Programs
  - How to Get the Programs
  - Using Cygwin
  - Using Single Unix programs
  - Where to Find More

If you start using Emacs on MS Windows you may find that some of the unix programs Emacs want to use are not there. Some of them (but not all) are available on MS Windows (because some people has taken the trouble to port them there). This page will tell you more about that.

## The Most Needed are Included in EmacsW32

The unix programs you probably needs most often with Emacs are included in EmacsW32:

cmp.exe diff.exe diff3.exe find.exe ftp.exe grep.exe locate.exe patch.exe sdiff.exe xargs.exe

Those are fetched from Gnuwin32. (Some of them may not be needed very often, but were in the packages from GnuWin32 so I added them anyway.) Beside those I included tidy.exe which can be used from nXhtml to tidy XHTML files.

## Most are Command Line Programs

Most of the unixs programs you may need are command line utilities and the easiest way to get Emacs to use them is to put them in your PATH. Some of the programs (like GhostScript and GSview) are not meant to be in your path on MS Windows. You can still add them to your PATH, but it may be a bit clumsy since they have their own bin directories. If you use EmacsW32 you can let Emacs find the program path for some of them.

## How to Get the Programs

There two principle ways to get the unix programs. You can get them as (rather) complete packages or as single programs. Cygwin and MSYS are such packages. If you use these alternatives the utility programs should normally be run from the command shell (sh.exe or bash.exe) that comes with them because they are meant to be used that way. MSYS is currently mostly meant to be used to as an environment for compiling programs with the GNU compilers (for example when porting unix programs to MS Windows). This means it is not as complete as Cygwin (which is a bigger download).

There have been problems with MSYS and Cygwin regarding file names, line endings (CRLF versus LF) and with automatic compression within Emacs. Now it seems to me that these things works with Cygwin (if you install it the "right" way), but not always with MSYS. I suggest you inside Emacs use Cygwin or single unix programs.

Single unix programs are fine most of the time, but unfortunately there is no really good port of a bash compatible shell to native MS Windows. You need such a shell for unpacking and installing some elisp packages. They come sometimes in a format that requires a unix sh command and then there are currently no good alternatives to using something like MSYS or Cygwin.

## Using Cygwin

I have installed Cygwin with "Default Text Type" set to "DOS / text". This allows Cygwin programs to recognize MS Windows style line endings which I need.

Cygwin has a setup program with which you download and install different parts. On the page Cygwin Package List you can search for programs you need and to find out which part of Cygwin you need to install.

Outside of Emacs you do not normally want Cygwin in your path. That could cause problems if Cygwin programs or DLLs have the same name as native windows dito. However inside Emacs it is convenient to have it first in your path. To easily setup Emacs to use Cygwin like this you can use w32shell.el (see the Emacs download area at ourcomments.org). With w32shell.el you can also add Emacs bin directory to the path and switch to Cygwin for interactive shells. Installation of some elisp packages is comfortable to do in an interactive Cygwin shell in Emacs where you have Emacs in the path.

In principle you can use MSYS the same way, but at the moment I do not recommend it.

## Using Single Unix programs

Many unix programs has been ported for use with MS Windows command shell (cmd.exe on the NT product line). Those are good for use inside of Emacs. A good starting point for such programs is Gnuwin32 (http://gnuwin32.sourceforge.net/). Gnuwin32 is divided into packages and sometimes it is hard to find the program you need. In this case it might be a good help to use for example Google to search the Gnuwin32 web site. (Search for example for site:gnuwin32.sourceforge.net packages diff.) You may also find the perl program I written to download and install Gnuwin32 packages useful, see Gnuwin32DL documentation (download here).

Note however that there is no updated unix style shell available that you easily can use together with the single unix programs.

## Where to Find More

There are some other programs you may need that are not included in any of the alternatives above. Gnuwin32 has a link page from which you may find some of those programs (for example GhostScript and GsView).

See also Building Emacs for other information.