When I open the Cygwin64 Terminal then does
Yes. I added some echo statements to the bash startup files and opened a Cywin64 Terminal. Here is the output:
For some reason
~/.bashrc is called twice, at the moment I'm not sure why.
The shortcut for the Cygwin64 Terminal runs the following command:
C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -
The help for
$ mintty --help
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.
So we can see the the trailing
- on the shortcut command causes a login shell to be run.
What happens next depends on what your login shell is set to.
Assuming it set to
If it is a login shell Cygwin will execute
~/.bash_profile if it exists or otherwise
.bash_profile will execute
If it is an interactive shell Cygwin will execute
.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.
Source Customizing bash