Please feel free to provide feedback or file bugs here.

aliases should be able to contain parameters

While PowerShell's introduction of aliases to Windows command lines is a (long due) help, they are very limited. Compared to aliases found in Linux shells such as bash, aliases in PowerShell have one glaring weakness: they can only replace a single token with another single token.

For example, on Linux, I can do the following:
# Add default parameters to ls so it shows hidden files and uses color
alias ls='ls -A --color=auto'
# Add an alias that shows ls long-form output and file type indicators
alias ll="ls -lF"

On Po9werShell, I can't do anything like that. "ls" is aliased to Get-ChildItem, but gci doesn't show hidden files by default, and *I cannot make an alias that does!*

# Create an alias that lists all contents (this command works)
Set-Alias lsa 'Get-ChildItem -Force'
# Try using that alias though...
lsa
lsa : The term 'Get-ChildItem -Force' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ lsa
+ ~~~
+ CategoryInfo : ObjectNotFound: (Get-ChildItem -Force:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

See https://msdn.microsoft.com/powershell/reference/5.1/microsoft.powershell.utility/Set-Alias. Yes, I can create a function and then alias the function, but that's way more complication and hassle than the way other shells implement aliases.

2 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)

    We’ll send you updates on this idea

    CBHackingCBHacking shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    0 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base