Sidor

lördag 29 december 2012

Tools - Setting up Cygwin

To start with, Cygwin is a great tool for Windows users. With Cygwin you get a Linux like console where you can do many Linux operations. For more information about Cygwin see there homepage: http://www.cygwin.com/.

So to my problem. It is common when I have to install my development environment on a new machine that I have forgot how Cygwin was setup and which packaged that used. It always ends by me searching for different parts about the installation, setup, and howtos. In this post I will go through how i have setup my Cygwin environment, and the most common packages which I use. We will have a look on the basic setup with a custom user home, configuration of the Cygwin terminal window and how one can configure some basic alias.

VI, good editor with a plentoria of functions. I am trying to use it instead of Emacs since most of the production environment does not have Emacs. Otherwise I would have used Emacs all the time.

Emacs (for some reason the latest version did not work (24.2-1). Instead I had to use versoion 23.4-3. The latest version of Emacs has a dependecy to cyggnutls-26.dll when cyggnutls-28.dll is boundle with the installation.

Openssh, ssh client.

Subversion, ye nothing fancy about it.

Screen, one of the best "session manager". Instead of having multiple Cygwin-windows use screen and you have multiple shells in one shell. More about Screen later on.

When all the packages are installed it is time to start up Cygwin for the first time. This step can be skipped, but then you will have to write some files from scratch when we are to change the home path.When starting Cygwin for the first time .bashrc and some other bash related stuff is created. These files works as there counterparts in Linux. Here you can setup alias and other things. See the files .bash_profile and .bashrc for more info.

To get the bash to work as expected we need to move some files. If you started Cygwin before changing the home path you can copy all the files in the old home folder. You will find the files in installation_dir\cygwin\home\user.

If you did not start Cygwin before add the following files to your new home path.

Alias is a good thing to use. You can see it as a shortcut for common commands you are using. As ls -la which you can create a alias for so you only type ll.

Open .bashrc and add the following to enable a alias which execute ls -la each time you type ll.

# Alias for long list.
alias ll='ls -la'

From here and on you can create which ever alias you like and also functions. In the default .bashrc file you have a lot of different nice things which you can have a look on. Remember that you need to restart you terminal window or bash it self for the new alias to be loaded.Styling your Cygwin window

In the past one could use a program called Mintty to enanhance the Cygwin terminal to look more modern with transparency and so on. Today Mintty is the default terminal for Cygwin, so one do not need to install anything extra. You only need configure it. Transparency here we go.

To configure Cygwin right click on the Cygwin icon in the terminal window and select option. Here you will find the configuration options. The following is the configuration I use.

Looks

Transparency: high

Window

Columns: 120

Rows: 40

Scrollback lines: 10000

A nice looking and transparent Cygwin terminal window.

That is it. Next time I am about to setup Cygwin again at least I know how I did it last.