Powershell: Feature Request: alias `which` => `Get-Command`

Created on 10 Oct 2019  路  4Comments  路  Source: PowerShell/PowerShell

Summary of the new feature/enhancement

PowerShell provides a variety of POSIX command aliases mapped to cmdlets. Ex: ls is a POSIX command, but in PowerShell it is an alias of Get-ChildItem. I propose adding another alias to this set of POSIX aliases, mapping which to Get-Command. Both POSIX which and PowerShell Get-Command serve the same purpose to users.

If this feature request is rejected, please explain how you determine whether an alias should ship with PowerShell or not.

Issue-Enhancement Resolution-Answered

Most helpful comment

If they were to add the alias, it would only be on Windows since it would mask the binary on non-Windows.

All 4 comments

If they were to add the alias, it would only be on Windows since it would mask the binary on non-Windows.

You are very correct and I was not aware. Is there a document on how aliases are chosen? Comparing aliases on Windows vs WSL, I'm not seeing a pattern.

In this vein, another alias I would like is touch => New-Item

Basically any alias that might conflict with a common or default Linux command will be disabled on Linux. They initially had many aliases that masked the native linux commands in 6.0.0, but Linux users didn't like it, so they were removed.

You of course can simply add some New-Alias calls to your profile script to set them for yourself.

@vexx32 is correct. Originally Windows PowerShell had many aliases that were common Linux commands to make it easier for Linux users to use Windows PowerShell. However, this created a problem once we made PowerShell Core cross platform. The common alias to use on Windows and non-Windows is gcm which is the alias for Get-Command. With this, you don't need to use which or where (depending on what OS you are on). As noted by @vexx32 you can always add your favorite aliases to your $profile.

Was this page helpful?
0 / 5 - 0 ratings