# Cygwin connection

Tera Term can connect to local Cygwin environment.
Cygwin is a Linux-like environment for Windows.
Cygwin is open source software.

[NOTE] Cygwin 1.5.x doesn't seem support Windows 7. Please use Cygwin 1.7.x or later on Windows 7 or later.

## Cygterm+

Tera Term uses the Cygterm+ program to connect local Cygwin.
Select "Cygwin connection" from "File" menu or press "Alt + G " to connect to Cygwin.

### Saving configuration

Be careful not to save [Setup] [Save setup] in the situation that it was started by cygterm.exe.
Otherwise telnet port number of TCP/IP is saved but 23 you will be confused by connection failure when you normally run Tera Term to do telnet. In that case it will be recovered by saving the setting with specifying TCP/IP Port# 23.

### How to search Cygwin

Tera Term must need to find the Cygwin installation path to launch the Cygterm+ program. So, Tera Term and cyglaunch will search the installation path in the following order.

1. TERATERM.INI
   1. Reads the CygwinDirectory entry in the TERATERM.INI file which is placed in the directory loaded by the teraterm.exe and the cyglaunch.exe directory.
   2. Searches the bin\cygwin1.dll file under the CygwinDirectory folder.
   3. Adds the bin\cygwin1.dll file into the PATH environment variable if the file exists.
   4. Launch the cygterm.exe program.
2. PATH environment variable
   1. Searches the bin\cygwin1.dll file into the directory included in the PATH environment variable.
   2. Launch the cygterm.exe program.
3. Round robin drive root
   1. Searches the bin\cygwin1.dll file under cygwin and cygwin64 directory of the drive direct root from C: to Z:.
   2. Searches the bin\cygwin1.dll file into the directory included in the PATH environment variable.
   3. Launch the cygterm.exe program.

The CygwinDirectory entry in the TERATERM.INI file will be empty when Tera Term is newly installed. If the automatic retrieval is failed, please configure the CygwinDirectory entry.
The format is "drive-letter:\directory".

    ----------------------------
    ; Cygwin install path
    CygwinDirectory = c:\cygwin
    ; 64bit Cygwin
    ; CygwinDirectory=c:\cygwin64
    ----------------------------

### 32bit Cygwin and 64bit Cygwin

A user needs an execution file by Tera Term needs the CygTerm+ program built on the 32bit Cygwin environment to connect 32bit Cygwin. And a user needs an execution file by Tera Term needs the CygTerm+ program built on the 64bit Cygwin environment to connect 64bit Cygwin.
Basically, Tera Term installation program will recognize the installed Cygwin version and copy an appropriate CygTerm+ program.
If the Tera Term installer makes an error in determination, please overwrite the cygterm.exe in the cygterm+-x86_64 directory to the Tera Term installation directory. Moreover, please rebuild the Cygterm+ source code.

### Build CygTerm+

When the cygterm.exe program can not work well, please rebuild the CygTerm+ source code.
Latest source code is included as cygterm+.tar.gz.

Packages that will need to be built
32bit Cygwin | Build 64bit Cygwin binary on 32bit Cygwin | 64bit Cygwin | Build 32bit Cygwin binary on 64bit Cygwin
--- | --- | --- | ---
Devel/make
Devel/gcc-g++ | Devel/cygwin64-gcc-g++ | Devel/gcc-g++ | Devel/cygwin32-gcc-g++

## Cygterm Here

When this option is selected on the Tera Term installer, the "Cygterm Here" context menu is added on the right-click and opened folder. A user can open the Cygwin connection on the selected folder.

Tera Term installer will configure the generic parameter, however the csh/tcsh may not check the CHERE_INVOKING. If indicated, please modify the /etc/csh.login file or modify the Cygterm Here registry in the following:

    before:
    "C:\Program Files\teraterm\cyglaunch.exe" -nocd -v CHERE_INVOKING=y -d "\"%L\""
    after:
    "C:\Program Files\teraterm\cyglaunch.exe" -nocd -nols -d "\"%L\""