Quando eu abro o Terminal Cygwin64, o /etc/bash.bashrc
é executado?
Resposta curta:
Sim. Eu adicionei algumas instruções de eco aos arquivos de inicialização do bash e abri um Terminal Cywin64. Aqui está a saída:
/etc/bash.bashrc
/home/DavidPostill/.bash_profile
.profile
/home/DavidPostill/.bashrc
/home/DavidPostill/.bashrc
$
Por algum motivo ~/.bashrc
é chamado duas vezes, no momento não tenho certeza do motivo.
Longa Resposta:
O atalho para o Terminal Cygwin64 executa o seguinte comando:
C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico -
A ajuda para mintty
afirma:
$ 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.
Assim, podemos ver que o comando -
no comando de atalho faz com que um shell de login seja executado.
O que acontece a seguir depende do seu shell de login está definido.
Assumindo que esteja definido como bash
, então:
-
Se for um shell de login, o Cygwin executará
~/.bash_profile
, se existir, ou~/.profile
.Observe que
.bash_profile
executará~/.profile
-
Se for um shell interativo, o Cygwin executará
~/.bashrc
.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.
Fonte Como personalizar o bash