Defining aliases in Cygwin under Windows

后端 未结 8 2004
情话喂你
情话喂你 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:30

    Here's a really quick and dirty way to do it, but it works fine for most things!

    Let's say you want to always run 'ls --color' instead of just 'ls'. Instead of messing around with .bashrc stuff, you can create a simple .bat file that essentially bootlegs the original ls command.

    Here's what I did:

    cd /bin
    echo ls2.exe %* --color > lsNew.bat
    mv ls.exe ls2.exe
    mv lsNew.bat ls.bat
    

    So now, whenever you type in ls from CMD, you actually are calling ls.bat, which in turn calls ls2.exe --color, the original ls command with the --color flag, along with the rest of the arguments, which are nicely passed through %*.

提交回复
热议问题