Sailor Family

Home

Sailor At Work

Firefox
Java
Rubik Cube
Toto/4D

Html
Perl
Chinese

Emacs/Cygwin









Drop me a note
Email Web Sailor
Welcome to Web Sailor's Home
Home > Emacs/Cygwin > Bash Shell

Cygwin Bash Shell in MS-DOS Prompt

After cygwin has been installed, a bash shell program can be invoked by double clicking on the cygwin.bat file. The .bash_profile and .bashrc files may be customized to suit your specific needs. It is definitely more stable to run Bash Shell using this method.

Please take note that both Emacs and Cygwin use the same HOME environment variable. You may refer to Emacs Installation for setting HOME environment variable.



Cygwin Bash Shell in rxvt Terminal

Bash Shell can also be run through the Cygwin's rxvt terminal distributed with cygwin. It is a colour vt102 terminal emulator intended as an xterm replacement. It can be launched without starting any X Window System. The terminal has some nice feature including familiar cut and paste operations (familiar to Unix users). It also offers better fonts.

Rxvt can be started by typing the following command in a command prompt window.

D:\Programs\Cygwin\bin\rxvt.exe -sl 500 -fn courier -bg wheat
-sr -title "Bash Sailor" -e D:\Programs\Cygwin\bin\bash.exe --rcfile %HOME%\.bashrc


I have placed a shortcut icon on my desktop so that rxvt can be launched easily by simply double clicking on the icon. The target of the shortcut is set to be the following
D:\programs\cygwin\bin\rxvt.exe -e d:\programs\cygwin\bin\bash.exe

In addition, I have placed the rest of the settings in a ~/.Xdefaults file as shown below.


          rxvt*title:             Bash
          rxvt*background:        wheat
          rxvt*foreground:        black
          rxvt*scrollBar_right:   true
          rxvt*colorBD:           1
          rxvt*font:              courier
          rxvt*saveLines:         10000
          rxvt.backspacekey:      ^?

          XTerm*saveLines:        5000
          XTerm*scrollBar:        true
          XTerm*rightScrollBar:   true



Cygwin Bash Shell in Mintty Terminal

Mintty is another terminal emulator distributed through cygwin. The good thing is that it supports UTF-8. Chinese characters can be displayed correctly.

MinTTY comes with GUI settings that allows users to set font, font color / size and etc.



Keyboard Customization

A little customization is needed for the keyboard so that the HOME and END keys work properly. You may need to add this line into the ~/.bashrc file.

export INPUTRC=$HOME/.inputrc
The content of the .inputrc file is
# Home Key
"\e[7~":beginning-of-line

# End Key
"\e[8~":end-of-line

# Delete Key
"\e[3~":delete-char

# Insert Key
"\e[2~":paste-from-clipboard



Problems with Bash Shell

First problem is Cygwin Bash shell does not recognize a DOS batch file by its .bat extension. Thus, typing autoexec in a Bash Shell will not invoke autoexec.bat. The solution is to type the entire file name including the .bat extension. Alternatively, alias such as "alias autoexec=autoexec.bat" may be set in the Bash Shell.

The second problem is, after a DOS batch file execution, the environment set by the batch file during the execution process will be gone. This is particularly annoying when trying to run vcvars32.bat to set system environment for Microsoft Visual C environment. One solution is to write an equivalent Bash Shell script to set the environment.

The third problem is only perculiar to rxvt. This a very difficult tty problem.



Langkawi Sunset