Defining aliases in Cygwin under Windows

后端 未结 8 1904
情话喂你
情话喂你 2021-01-17 09:58

I am trying to define some aliases in cygwin, but with no success. I am doing so like this at the end of the .bashrc file.

alias foo=\'pwd\'
         


        
8条回答
  •  暖寄归人
    2021-01-17 10:51

    I had the same issue, where the aliases added to ~/.bashrc didn't work. It seems that, for some reason, the ~/.bashrc was not executed when launching the console.

    I stumbled upon a response that fixes the issues

    So, you need to create a .bash_profile file. This one seems to be the default script, and put this code in it, to ensure that the .bashrc is executed.

    # ~/.bash_profile: executed by bash for login shells.
    
    if [ -e /etc/bash.bashrc ] ; then
     source /etc/bash.bashrc
    fi
    
    if [ -e ~/.bashrc ] ; then
     source ~/.bashrc
    fi
    

    That works for me, just make sure that .bash_profile is executable. (chmod +x ~/.bash_profile)

提交回复
热议问题