Cygwin + Windows Terminal

date:

tags: chocolatey cygwin windows terminal windows

categories: Windows

Cygwin is a collection of open source tools that are commonly found on GNU/Linux systems but not found on Windows systems. It includes a library for x86_64 Windows systems that provides some POSIX API functionality.

Installing Cygwin

If you set up Windows 10 per my previous post, you already have this utility installed. If not, I recommend using Chocolatey to install and maintain this software.

1
choco install cygwin

If you install Cygwin via chocolatey, the binary will be located in:

C:\ProgramData\chocolatey\bin\Cygwin.exe

Add Cygwin to Windows Terminal

In my aforementioned post, I installed the Windows Terminal via Chocolatey also. I highly recommend using this as your terminal on Windows 10 systems. It is GPU accelerated and supports adding multiple “tabs” making terminals easier to organize. This terminal is included on Windows 11 Systems.

Windows Terminal config

Open the terminal and access the settings by pressing [ Ctrl ] + [ , ]

On the left-hand bar of the terminal, navigate to the + icon to create a new Profile. Alternatively, press the Gear at the bottom of the left-hand bar and that will open the settings JSON file. I have the example profile in JSON in the next section.

image
image

Name the profile Cygwin or whatever you prefer and enter the location of the Cygwin binary as the Command line. You can adjust the appearance in the next tab.

image1
image1

Windows Terminal JSON config profile

1
2
3
4
5
6
7
{
     "colorScheme": "Vintage",
     "commandline": "C:\\ProgramData\\chocolatey\\bin\\Cygwin.exe",
     "cursorShape": "emptyBox",
     "experimental.retroTerminalEffect": true,
     "name": "Cygwin"
}

The important settings here are “name” and “commandline”, the rest is a silly theme that makes the terminal look like it is on a CRT monitor.

Opening the new profile

Press the + on the top bar and select “Cygwin” to open your new profile.

cygwin
cygwin

This will open a new terminal tab with the Cygwin bash shell. Entering the command help will display information about the shell.

1
2
3
4
5
6
7
8
$ help
GNU bash, version 4.4.12(3)-release (x86_64-unknown-cygwin)
These shell commands are defined internally.  Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.

A star (*) next to a name means that the command is disabled.

Notable commands and directories

When using Cygwin, you can use bash utilities for browsing files on your computer.

  • clear : will clear the output in the terminal window.
  • ls : list directory contents
    • ls -a : option added to show hidden files (files that start with “.”)
  • pwd : display the current directory path in the file system.
  • man [command] : open the manual page for specified command in the current terminal window.

Windows drive letters

Windows will assign drive letters to partitions. In Cygwin, these are mounted as /cygdrive/N. For example, if you are looking for folder D:\videos in Cygwin it would be under /cygdrive/d/videos

Cygwin User guide

https://cygwin.com/cygwin-ug-net.html

comments powered by Disqus