Cygwin shell doesn't execute .bashrc

前端 未结 5 487
轮回少年
轮回少年 2020-12-10 02:41

After start the cygwin shell, it just locate in a wrong home dir:

xfire@codingme.com ~
$ pwd
/cygdrive/c/Users/xfire

But it used to be /hom

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 03:23

    On my version of cygwin I found that only ~/.profile was being execueted so added

    if [ -e "${HOME}/.bash_profile" ]; then
        source "${HOME}/.bash_profile"
    fi
    

    to the .profile file. My .bash_profile file contains another test for .bashrc and executes that from inside there. I also added the following two lines to my .bashrc file.

    export BASH_ENV="${HOME}/.profile"
    export ENV="${HOME}/.profile"
    

    The first of these ensures that .profile gets executed in non-interactive terminals and the second ensures it gets executed in POSIX terminals. I found a very useful explanation of what get run and when in the Bash Reference Manual.

    In your case it wouldn't help as you have an issue with the value of your HOME environment variable but this page comes up quite high on the list when searching for this issue.

提交回复
热议问题