Environment Variables
Before starting bash, you may set some environment variables. A .bat
file is provided where the most important ones are set before bash in
launched. This is the safest way to launch bash initially. The .bat
file is installed in the root directory that you specified during setup
and pointed to in the Start Menu under the "Cygwin" option. You can
edit it this file your liking.
The CYGWIN variable is used to configure many global
settings for the Cygwin runtime system. Initially you can leave
CYGWIN unset or set it to tty (e.g.
to support job control with ^Z etc...) using a syntax like this in the
DOS shell, before launching bash.
C:\> set CYGWIN=tty notitle glob
The PATH environment variable is used by Cygwin
applications as a list of directories to search for executable files
to run. This environment variable is converted from Windows format
(e.g. C:\WinNT\system32;C:\WinNT) to UNIX format
(e.g., /WinNT/system32:/WinNT) when a Cygwin
process first starts.
Set it so that it contains at least the x:\cygwin\bin
directory where "x:\cygwin is the "root" of your
cygwin installation if you wish to use cygwin tools outside of bash.
The HOME environment variable is used by many programs to
determine the location of your home directory and we recommend that it be
defined. This environment variable is also converted from Windows format
when a Cygwin process first starts. Set it to point to your home directory
before launching bash.
The TERM environment variable specifies your terminal
type. It is automatically set to cygwin if you have
not set it to something else.
The LD_LIBRARY_PATH environment variable is used by
the Cygwin function dlopen () as a list of
directories to search for .dll files to load. This environment variable
is converted from Windows format to UNIX format when a Cygwin process
first starts. Most Cygwin applications do not make use of the
dlopen () call and do not need this variable.
Changing Cygwin's Maximum Memory
By default no Cygwin program can allocate more than 384 MB of memory
(program+data). You should not need to change this default in most
circumstances. However, if you need to use more real or virtual memory in
your machine you may add an entry in the either the
HKEY_LOCAL_MACHINE (to change the limit for all users) or
HKEY_CURRENT_USER (for just the current user) section of
the registry.
Add the DWORD value heap_chunk_in_mb
and set it to the desired memory limit in decimal MB. It is preferred to do
this in Cygwin using the regtool program included in the
Cygwin package.
(For more information about regtool or the other Cygwin
utilities, see or use each the
--help option of each util.) You should always be careful
when using regtool since damaging your system registry can
result in an unusable system. This example sets memory limit to 1024 MB:
regtool -i set /HKLM/Software/Cygnus\ Solutions/Cygwin/heap_chunk_in_mb 1024
regtool -v list /HKLM/Software/Cygnus\ Solutions/Cygwin
Exit all running Cygwin processes and restart them. Memory can be allocated up
to the size of the system swap space minus any the size of any running
processes. The system swap should be at least as large as the physically
installed RAM and can be modified under the System category of the
Control Panel.
Here is a small program written by DJ Delorie that tests the
memory allocation limit on your system:
main()
{
unsigned int bit=0x40000000, sum=0;
char *x;
while (bit > 4096)
{
x = malloc(bit);
if (x)
sum += bit;
bit >>= 1;
}
printf("%08x bytes (%.1fMb)\n", sum, sum/1024.0/1024.0);
return 0;
}
You can compile this program using:
gcc max_memory.c -o max_memory.exe
Run the program and it will output the maximum amount of allocatable memory.
Customizing bash
To set bash up so that cut and paste work properly, click on the
"Properties" button of the window, then on the "Misc" tab. Make sure
that "Quick Edit" is checked and "Fast Pasting" isn't. These settings
will be remembered next time you run bash from that
shortcut. Similarly you can set the working directory inside the
"Program" tab. The entry "%HOME%" is valid.
Your home directory should contain three initialization files
that control the behavior of bash. They are
.profile, .bashrc and
.inputrc. These initialization files will only
be read if HOME is defined before starting bash.
.profile (other names are also valid, see the bash man
page) contains bash commands. It is executed when bash is started as login
shell, e.g. from the command bash --login.
This is a useful place to define and
export environment variables and bash functions that will be used by bash
and the programs invoked by bash. It is a good place to redefine
PATH if needed. We recommend adding a ":." to the end of
PATH to also search the current working directory (contrary
to DOS, the local directory is not searched by default). Also to avoid
delays you should either unset MAILCHECK
or define MAILPATH to point to your existing mail inbox.
.bashrc is similar to
.profile but is executed each time an interactive
bash shell is launched. It serves to define elements that are not
inherited through the environment, such as aliases. If you do not use
login shells, you may want to put the contents of
.profile as discussed above in this file
instead.
shopt -s nocaseglob
will allow bash to glob filenames in a case-insensitive manner.
Note that .bashrc is not called automatically for login
shells. You can source it from .profile.
.inputrc controls how programs using the readline
library (including bash) behave. It is loaded
automatically. For full details see the Function and Variable
Index section of the GNU readline manual.
Consider the following settings:
# Ignore case while completing
set completion-ignore-case on
# Make Bash 8bit clean
set meta-flag on
set convert-meta off
set output-meta on
The first command makes filename completion case insensitive, which can
be convenient in a Windows environment. The next three commands allow
bash to display 8-bit characters, useful for
languages with accented characters. Note that tools that do not use
readline for display, such as
less and ls, require additional
settings, which could be put in your .bashrc:
alias less='/bin/less -r'
alias ls='/bin/ls -F --color=tty --show-control-chars'