Tuesday, March 1, 2011

Using mintty for Cygwin and bash (or your preferred shell)

I installed Cygwin with the default options, but did not like how the terminal window was based on the Windows CMD (command line).  I did some reading and found that many people recommend mintty which is based off PuTTY v0.60, arguably a better terminal interface.

However once you install mintty, you don't automatically get your shell.  Running mintty from the Start menu or shortcut icons just dropped me into the /usr/bin directory with limited shell functionality (couldn't do ls, etc. but could do cd).  Weird.  The way to get this right is to edit the C:\Cygwin\cygwin.bat file from Windows, remove or comment out the default shell call, for example:
@echo off
C:
chdir C:\cygwin\bin
REM bash --login -i
start mintty.exe c:\cygwin\bin\bash --login -i

You also might want to look into other startup options such as sizing of the window; you have different options  like:

start mintty.exe -s 120,60 c:\cygwin\bin\bash --login -i           [opens a mintty window with 120 cols, 60 rows in size]

start mintty.exe -w max c:\cygwin\bin\bash --login -i           [opens a mintty window Maximized on your desktop]

Check out some other tips on using mintty:

Tips - mintty - Tips on setting up mintty and related programs


mintty usage and arguments:


Usage: mintty [OPTION]... [ PROGRAM [ARG]... | - ]


Start a new terminal session running the specified program or the user's shell.
If a dash is given instead of a program, invoke the shell as a login shell.


Options:
  -e, --exec            Treat remaining arguments as the command to execute
  -p, --position X,Y    Open window at specified coordinates
  -s, --size COLS,ROWS  Set screen size in characters
  -w, --window normal|min|max|full  Set initial window state
  -t, --title TITLE     Set window title (default: the invoked command)
      --class CLASS     Set window class name (default: mintty)
  -i, --icon FILE[,IX]  Load window icon from file, optionally with index
  -l, --log FILE        Log output to file
  -u, --utmp            Create a utmp entry
  -h, --hold never|always|error  Keep window open after command terminates?
  -c, --config FILE     Load specified config file
  -o, --option OPT=VAL  Override config file option with given value
  -H, --help            Display help and exit
  -V, --version         Print version information and exit

3 comments:

  1. All of that isn't necessary. Just create a new shortcut to

    C:\cygwin\bin\mintty.exe /bin/bash --login -i

    ReplyDelete
    Replies
    1. Thanks! Exactly what I was looking for.

      Delete