Defining aliases in Cygwin under Windows

后端 未结 8 1900
情话喂你
情话喂你 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)

    0 讨论(0)
  • 2021-01-17 10:55

    I had the same problem, but I was using ConEmu to run my console. I had to go into settings and change the settings from this :

    set CHERE_INVOKING=1 & %ConEmuDrive%\Programs\Cygwin\bin\sh.exe --login -i -new_console:C:"%ConEmuDrive%\Programs\Cygwin\Cygwin.ico"

    to this:

    set HOME= & set CHERE_INVOKING=1 & %ConEmuDrive%\Programs\Cygwin\bin\bash.exe --login -i -new_console:C:"%ConEmuDrive%\Programs\Cygwin\Cygwin.ico"

    Then it would work correctly.

    0 讨论(0)
提交回复
热议问题