启动cygwin shell后,它只是位于错误的主目录中:
xfire@codingme.com ~
$ pwd
/cygdrive/c/Users/xfire
Run Code Online (Sandbox Code Playgroud)
但它曾经是/ home/xfire
xfire@codingme.com /etc
$ cat passwd | grep xfire
xfire:unused:22773:10513:U-CORP\xfire,S-1-5-21-527237240-725345543-682003330-12773:/home/xfire:/bin/bash
Run Code Online (Sandbox Code Playgroud)
并且/ home/xfire中的.bashrc没有被执行,即使我将它复制到/ cygdrive/c/Users/xfire,它也不起作用!
gle*_*man 34
在cygwin上,我将此添加到我的~/.bash_profile:
. ~/.bashrc
Run Code Online (Sandbox Code Playgroud)
Eva*_* Y. 10
某些程序在Windows注册表中添加"HOME"环境并将值设置为"C:\ Users\xfire",这就是为什么cygwin将该目录作为主目录.cygwin.com/faq-nochunks.html
在我的cygwin版本中,我发现只有~/.profile被执行了,所以添加了
if [ -e "${HOME}/.bash_profile" ]; then
source "${HOME}/.bash_profile"
fi
Run Code Online (Sandbox Code Playgroud)
到.profile文件。我的.bash_profile文件包含另一个测试,.bashrc并从那里执行。我还在文件中添加了以下两行.bashrc。
export BASH_ENV="${HOME}/.profile"
export ENV="${HOME}/.profile"
Run Code Online (Sandbox Code Playgroud)
这些中的第一个确保可.profile在非交互式终端中执行,第二个确保可在POSIX终端中执行。在Bash参考手册中,我找到了关于运行什么以及何时运行的非常有用的解释。
对于您而言,这无济于事,因为您的HOME环境变量的值存在问题,但是在搜索此问题时,此页面在列表中的位置很高。