Powershell: Show alias

Created on 26 Jan 2020  路  3Comments  路  Source: PowerShell/PowerShell


Objective: Increase the frequency of alias use,Reduce learning costs

Steps to reproduce

Type tabs to display aliases


Expected behavior

PS >get-process <tab>
gps -> Get-Process

PS >Get-It <tab>
gi -> Get-Item               gp -> Get-ItemProperty       gpv -> Get-ItemPropertyValue

Actual behavior

PS >Get-It <tab>
Get-Item               Get-ItemProperty       Get-ItemPropertyValue

Environment data


Issue-Question Resolution-Answered

Most helpful comment

I am not convinced about the need for this.

In general, best practice suggests NOT using aliases in production code. Encouraging more use seems to be anti-best practice. For that reason alone, I am not keen on this idea.

BUT: this might be useful in an interactive session where terseness can be a virtue. However,
I teach students to do this:

gal -def get-alias

I also train them on when and when not to use aliases.

Even if we wanted this feature, using Tab today does do _something useful, If you type a tab after a cmdlet name, PowerShell iterates through items based on the cmdlet (eg with Get-Alias it runs through the aliases, Get-ChildItem runs through files. Changing this behaviour to show aliases is not helpful. Tabl Completion is about _completing_ a command line, not in showing alternatives (eg aliases).

TL;DR - I am not convinced we need such a device and in any case, it changes existing behaviour in a way less helpful.

All 3 comments

I am not convinced about the need for this.

In general, best practice suggests NOT using aliases in production code. Encouraging more use seems to be anti-best practice. For that reason alone, I am not keen on this idea.

BUT: this might be useful in an interactive session where terseness can be a virtue. However,
I teach students to do this:

gal -def get-alias

I also train them on when and when not to use aliases.

Even if we wanted this feature, using Tab today does do _something useful, If you type a tab after a cmdlet name, PowerShell iterates through items based on the cmdlet (eg with Get-Alias it runs through the aliases, Get-ChildItem runs through files. Changing this behaviour to show aliases is not helpful. Tabl Completion is about _completing_ a command line, not in showing alternatives (eg aliases).

TL;DR - I am not convinced we need such a device and in any case, it changes existing behaviour in a way less helpful.

In general, best practice suggests NOT using aliases in production code. Encouraging more use seems to be anti-best practice. For that reason alone, I am not keen on this idea.

Agree

A better solution would be to have a PS Readline keybinding which shows get-alias -definition [current token] but not bind it to tab.

This issue has been marked as answered and has not had any activity for 1 day. It has been closed for housekeeping purposes.

Was this page helpful?
0 / 5 - 0 ratings