# cygwin(3)

[Home] [Commands] [Variables] [Macro-Dev] [Glossary]

## NAME

cygwin - Open a Cygwin BASH window
%cygwin-path - Cygwin root directory
%cygwin-hilight - Cygwin shell hilight enable flag
%cygwin-prompt - Cygwin shell prompt

## PLATFORM

Windows '95/'98/NT/2K/XP - win32 ONLY

## SYNOPSIS

cygwin

%cygwin-path "path"
%cygwin-hilight [`0`|`1`]
%cygwin-prompt "hilightString"

## DESCRIPTION

cygwin creates an interactive BASH shell window within a MicroEmacs buffer window, providing a UNIX command line facility within the Microsoft Windows environment. This is a preferable environment to the MS-DOS shell and is certainly far more comfortable for those familiar with UNIX.

Within the window BASH commands may be entered and executed, the results are shown in the window. Within the context of the BASH shell window then directory naming conforms to the cygwin standard conventions (as opposed to the Microsoft directory naming).

On running cygwin a new buffer is created called `*cygwin*` which contains the shell. Executing the command again creates a new shell window called `*cygwin1*`, and so on. If a cygwin window is killed off then the available window is used next time the command is run.

Additional controls are available within the shell window to control the editors interaction with the window. The operating mode is shown as a digit on the buffer mode line (2/3/4) which is defined in the following sections. The operational mode is changed with the F3 function key.

Mode 2 - Browse Mode

Locks the window and allows local editing to be performed. All commands entered into the window are interpreted by the editor. Mode 2 is typically entered to cut and paste from the window, search for text strings etc. In mode 2, a 2 is shown on the mode line.

Mode 3 - Semi-immersion

The normal operating mode, text typed into the window is presented to the shell window. Translation of MicroEmacs commands (i.e. beginning-of-word) are translated and passed to the shell. For interactive use this is the default mode. In mode 3, a 3 is shown on the mode line.

Mode 4 - Full Immersion

All input is passed to the shell, no MicroEmacs commands are interpreted and keys are passed straight to the shell window. This mode is used where none of the keys to be entered are to be interpreted by MicroEmacs. Note that you have to un-toggle mode 4 before you can swap buffers as this effectively locks the editor into the window.

F5

Clears the buffer contents. This simply erases all of the historical information in the buffer. The operation of the shell is unaffected.

To exit the shell then end the shell session using "`exit`" or "`C-d`" as normal and then close the buffer. A short cut "`C-c C-k`" is available to kill off the pipe. However, it is not recommended that this method is used as it effectively performs a hard kill of the buffer and attached process

%cygwin-path is a user defined variable that defines the file system location of the cygwin directory, this is typically `c:/cygwin`. If cygwin is located at a different location then the variable MUST be defined within the user start up script in order for the cygwin command to start the shell. With a default installation of cygwin then the settings are typically defined as:-

Current Release

    set-variable %cygwin-path "c:/cygwin"

%cygwin-hilight is a boolean flag which controls how the cygwin command shell window is hilighted. This value MUST be defined within the user start up script prior to executing cygwin if hilighting is to be disabled; by default hilighting is enabled. A value of 0 disables shell hilighting i.e.

    set-variable %cygwin-hilight 0

%cygwin-prompt is an optional variable that is used in conjunction with %cygwin-hilight, it defines the hilighting string identifying the prompt. This allows the prompt to be rendered with a different color. The default prompt is `bash-x.yyr$` and may be hilighted using a definition:-

    set-variable %cygwin-prompt "bash-2.01$"

The user typically overrides the prompt definition within the BASH startup file, a more appropriate definition of the prompt may be:-

    set-variable %cygwin-prompt "^[a-z]*@[^>]*>"

## NOTES

The cygwin command uses the ipipe-shell-command(2) to manage the pipe between the editor and the bash shell. The window is controlled by the macro file `hkcygwin.emf` which controls the interaction with the shell.

The macro cygwin in `hkcygwin.emf` defines the parameter setup to connect to the cygwin bash shell, installed in the default location `c:/cygwin`. If your installation of cygwin is in a different location then correct the macro to match your install location, preferably correct by creating a mycygwin.emf file in your user directory simply containing a re-defined cygwin macro.

If you have exported some of the cygwin environment variables in your `autoexec.bat` then you will have to figure out for yourself what variables macro cygwin needs to export - the current configuration is for a vanilla install.

The bash shell is executed with options -i, for interactive shell and -m to enable job control.

As of the 2004 release then the Cygwin/Cygnus support has been revised in light of the changes in cygwin

- Renamed the command from cygnus to cygwin.
- Following a change in the bash(1) command line operation, which now no longer echos user input, then the user input is processed by MicroEmacs. This does cause some problems with completion as the Cygwin environment has a different name space. The completion still requires some more work, but sufficient for smaller tasks.

## TESTED CONFIGURATIONS

This configuration has only been tested on a Windows 2000 installation, whether this works on Windows 95/98/NT is unknown while XP is very likely to work.

We have only been running "make" operations in the shell and do not know how the likes of "more", "man" or anything other terminal interaction works.

Tested Configurations

Windows 2K (Pentium-4) and Windows 2K (SunPCi-III)

cygwin latest version as of February 2004.

## BUGS

Break Key

A break in a bash shell is `C-c`, the macros define the key `C-c C-c` to perform the break. There does not appear to be a way to prevent this from happening as trapping the interrupt does not appear to be supported in Cygwin Bash i.e. "`trap` `''` `INT`".

Completion

Completion processing needs to be improved. The directory location is retrieved from bash(1) on each command line prompt, this is used for file completion. There is no command completion. Room for some improvement here.

## SEE ALSO

ipipe-shell-command(2), ishell(3).
Cygwin home site www.cygwin.com

(c) Copyright JASSPA 2009
Last Modified: 2009/08/29
Generated On: 2009/10/12

</HMTL>