PowerShell / PowerShell

PowerShell for every system!
https://microsoft.com/PowerShell
MIT License
43.55k stars 7.06k forks source link

Set-Alias: Add ability for parameters of ResolvedCommand #21603

Closed 237dmitry closed 2 weeks ago

237dmitry commented 2 weeks ago

Summary of the new feature / enhancement

Not to write scripts, functions or install 3party modules.

For example:

Set-Alias -Name ttymc -Value "mc -bS default"
Set-Alias -Name ttymc -Value mc -ArgumentList "-b -S default"

instead of:

function Start-mcOnTTY
{
    [Alias('ttymc')]
    param ()

    if ($env:TERM -eq 'linux') { bash -c "mc -bS default" }
    else { bash -c mc }
}

Like in bash. alias alias_name="Command --with-parameters"

Proposed technical implementation details (optional)

No response

mklement0 commented 2 weeks ago
Set-Item Function:ttymc 'mc -bS default @args'
kilasuit commented 2 weeks ago

This I think is a similar enough request to #12962 that can close this as Resolution-Duplicate

237dmitry commented 2 weeks ago

this as Resolution-Duplicate

Not to write scripts, functions or install 3party modules.

This is not resolution. Because function is not an alias. This is feature request and not looking for workaround.

mklement0 commented 2 weeks ago

The linked duplicate explicitly asks for an alias-based solution.

237dmitry commented 2 weeks ago

The linked duplicate explicitly asks for an alias-based solution.

I couldn't find a solution there. Just a workaround with functions. I want to get rid of the alias functions because there is a list of natural aliases and a few other functions. In my opinion, this is generally not neat, but I like order when everything is in its place.. The only good thing is that aliases of functions are displayed with Get-Alias cmdlet.

If it duplicate https://github.com/PowerShell/PowerShell/issues/12962 then I will close this issue tomorrow.

mklement0 commented 2 weeks ago

Generally speaking, @237dmitry:

It is asking for the same thing / reporting the same problem that makes a preexisting issue a duplicate, not whether or not the thing that was asked for has since been implemented / a (satisfying) workaround has been posted.

As for a unified discovery mechanism for different command forms: that's what Get-Command is for.

microsoft-github-policy-service[bot] commented 2 weeks ago

📣 Hey @237dmitry, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

Microsoft Forms