Posts Tagged ‘cygwin’

CygWin terminal colors

November 14th, 2010 No comments

Many of the default ANSI colors used by the CygWin terminal are almost unreadable. For example, the blue that is used for directories in a file listing is pretty dark and hard to read on a black background. This limits the color palette that can be used in things such as the PS1 shell prompt. Try the following script ( to see what your colors currently look like.

The colors can be changed by clicking on the system menu in the upper-left corner and selecting “Properties”. I decided to use the same colors as the Gnome terminal.

This is how the colors are defined in CygWin by default:

Color R G B
Black 0 0 0
Blue 0 0 128
Green 0 128 0
Cyan 0 128 128
Red 128 0 0
Pruple 128 0 128
Brown 128 128 0
Light Gray 192 192 192
Dark Gray 128 128 128
Light Blue 0 0 255
Light Green 0 255 0
Light Cyan 0 255 255
Light Red 255 0 0
Light Purple 255 0 255
Light Yellow 255 255 0
White 255 255 255

This is how they should be changed so that they’re more usable:

Color R G B
Black 0 0 0
Blue 0 0 170
Green 0 170 0
Cyan 0 170 170
Red 170 0 0
Pruple 170 0 170
Brown 170 85 0
Light Gray 170 170 170
Dark Gray 85 85 85
Light Blue 85 85 255
Light Green 85 255 85
Light Cyan 85 255 255
Light Red 255 85 85
Light Purple 255 85 255
Light Yellow 255 255 85
White 255 255 255
Categories: Uncategorized Tags: , ,

Git on Windows

October 9th, 2009 No comments

One of the problems with using git on Windows is that it’s difficult to integrate it with other native (Windows) tools. That’s because the environment git runs in (cygwin or msysgit) refers to files by their UNIX name, but the Windows tools have no notion of where /tmp is for example (and that location can be different between cygwin and msysgit).

When doing an interactive rebase, the editor might be asked to edit a file such as /cygdrive/c/some/path/to/a/file. When doing a diff in git, one or both of the files to be diff’d might be placed by git in /tmp. Windows tools don’t understand such path names.

Fortunately, cygwin ships with a utility called cygpath that can be used to convert between UNIX and Windows paths. Msysgit doesn’t have this utility, but if cygwin’s /bin directory is in your Windows path, msysgit will pick it up and the scripts below will be usable for both cygwin and msysgit.

Here’s a script that can be used as a wrapper around your editor:


# Author: Gabriel Burca
# Script arguments:
# file-to-edit

FILE=`cygpath -w "${1}"`
"C:/Program Files/Vim/vim72/gvim.exe" "$FILE"
This script can be used as a wrapper around your diff tool:

# Author: Gabriel Burca
# Script arguments:
# path old-file old-hex old-mode new-file new-hex new-mode

# The old-file path is typically "/tmp/.diff_something" and windows programs
# don't know how to get to "/tmp"
# We use cygpath to convert to something windows programs understand.

OLD_FILE=`cygpath -w "${2}"`
NEW_FILE=`cygpath -w "${5}"`
"C:/Program Files/WinMerge/WinMergeU.exe" -e -ub "$OLD_FILE" "$NEW_FILE"
Finally, you'll need to modify ~/.gitconfig to use these scripts by adding something like this to it:
external = "C:/Utility/"
editor = "C:/Utility/"
Categories: Uncategorized Tags: , , , ,

Cygwin vs. Msysgit

September 22nd, 2009 2 comments

Both cygwin and the msysgit shell will use the same ~/.bashrc file on start-up, but they mount the local Windows drives at different mount points. Cygwin uses /cygdrive/c while msysgit uses simply /c so if you’re using ~/.bashrc to configure various settings that have to do with drive letters in your bash shell, you’ll need to distinguish between cygwin and msysgit.

The easiest way to do this is to look for the presence of /etc/bash.bashrc in ~/.bashrc, since this file is typically only present in cygwin. If by any chance it’s present in both cygwin and msysgit, a variable can be set in just one of them and ~/.bashrc can be configured to source /etc/bash.bashrc and test for the presence of that variable.

if [ -e /etc/bash.bashrc ] ; then
# Cygwin specific settings
export CYGWIN=1

# Msysgit's grep doesn't recognize --color
alias grep='grep --color'
alias vi='/cygdrive/c/Program\ Files/Vim/vim72/gvim.exe'
# Msysgit specific settings
export CYGWIN=0

alias vi='/c/Program\ Files/Vim/vim72/gvim.exe'
Categories: Uncategorized Tags: , , , ,