Search code examples
bashcygwinalias

Cygwin reads bashrc but yet doesn't remember aliases


I've tried to setup cygwin with aliases.

I've used the default .bashrc but uncomented the aliases for ls, la ... etc.

I've placed it under C:\Users\Dimitar which is my home directory, and added a line $HOME/.bashrc in /etc/profile.

when i type alias, or try to use one i get nothing.

I've added echo "LOADED" at the end of it, and i see loaded when i run cygwin, but still no aliases.

What is the problem and how an i fix it?


Solution

  • Make sure you're using .bashrc and that it's not commented out in .bash_profile:

    # source the users bashrc if it exists
    if [ -f "${HOME}/.bashrc" ] ; then
      source "${HOME}/.bashrc"
    fi
    

    If you want to use a separate alias file make sure the appropriate lines are uncommented in .bashrc and that you've specified the file you'd like to use. For example .bash_aliases is common.

    # Some people use a different file for aliases
    if [ -f "${HOME}/.bash_aliases" ]; then
      source "${HOME}/.bash_aliases"
    fi
    

    That should really be all you need. Sample syntax within the aliases file:

    $ cat .bash_aliases
    alias shelldir'=cd /cygdrive/c/Dropbox/Dev/Shell'