How can I make cygwin commands a priority over built in windows commands?

1

If I run ls in powershell the windows built in ls function is run.

how can I make cygwin ls run instead?

I've tried moving cygwin/bin to top begin system path variable, but that didn't work.

is this normal?

mars

Posted 2014-04-01T12:28:00.870

Reputation: 111

Can you even run cygwin commands in PowerShell? I though cygwin had its own shell. – dangph – 2014-04-02T01:18:13.613

it does have it's own shell but since the commands are all EXEs you can run them, and it's pretty smooth (add the cygwin/bin dir to your system path) I solved this by removing the powershell "ls" alias – mars – 2014-04-02T08:12:10.310

ls was the only command I really needed so I can do ls --color :) – mars – 2014-04-02T08:12:48.617

Answers

0

In powershell, 'ls' is an alias. The simplest way to remove it is to add one of the following to your $PSPROFILE:

Remove-Item Alias:\ls

Alternatively, you can replace it with:

Set-Alias -Name:"ls" -Value:"ls.exe" -Option:Allscope

Just remember that powershell aliases cannot include arguments. If you need an argument, create a function first:

# The --% Is a powershell3+ feature to say "don't parse the rest of this line"
function lsFunc { ls.exe --% --color }
Set-Alias -Name:"ls" -Value:lsFunc -Option:AllScope

Eris

Posted 2014-04-01T12:28:00.870

Reputation: 463