Cygwin shell doesn't execute .bashrc

前端 未结 5 478
轮回少年
轮回少年 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:09

    You can also also set BASH_ENV variable, e.g., BASH_ENV='C:\DOCUME~1\dwyttenb\.bashrc'

    0 讨论(0)
  • 2020-12-10 03:09

    ~/.bash_profile is executed before the initial command prompt is returned to the user. After that, every time a new shell is opened, ~/.bashrc is executed.

    Adding . ~/.bashrc at end of ~/.bash_profile has resolved the problem.

    Now you can check existing aliases using alias command.

    Find more details on github.

    0 讨论(0)
  • 2020-12-10 03:18

    Some program add an "HOME" environment in windows registry and set the value to "C:\Users\xfire", that's why cygwin take that directory as the home. cygwin.com/faq-nochunks.html

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-10 03:27

    On cygwin, I add this to my ~/.bash_profile:

    . ~/.bashrc
    
    0 讨论(0)
提交回复
热议问题