Список псевдонимов

When I install something like ffmpeg with winget, it sets permanent aliases for ffmpeg, ffplay, & ffprobe.

winget install gyan.ffmpeg

It doesn’t look like it’s adding anything to my path environment variable. If I use the Set-Alias PowerShell utility, said alias is ephemeral, only lasting until the end of the current session. Eventually, I found that I can use my $profile to denote a list of aliases that instantiate every time I launch my shell.

Does winget do the same thing just with a different “profile” file? Is there a better way of doing this?

DavidPostill's user avatar

77 gold badges365 silver badges408 bronze badges

asked Sep 9, 2023 at 9:02

ninbura's user avatar

WinGet creates symlinks in this folder. These are then usable from any shell or Run prompt.

In my opinion, yes, this method is superior, because it is effective everywhere.

However, it only works with .exe files. If you need PowerShell-specific aliases (involving cmdlets or whatever), you must use PowerShell methods to create them permanently. $profile is the way to go.

answered Sep 15, 2023 at 8:17

Daniel B's user avatar

Daniel B

9 gold badges128 silver badges176 bronze badges

From the post
How to create permanent PowerShell Aliases,
I quote the excellent
answer by Naigel :

To answer your question, you only have to create a profile.ps1 file
containing the code you want to be executed, that is:

New-Alias Goto Set-Location

and save it in the proper path:

  • "$Home\Documents" (usually C:\Users\<yourname>\Documents): only your user will execute the code. This is the recommended location You
    can quickly find your profile location by running echo $profile in
    PowerShell
  • $PsHome (C:\Windows\System32\WindowsPowerShell\v1.0): every user will execute this code

IMPORTANT: remember you need to restart your PowerShell instances to apply the changes.

  • The paths are:

  • C:\Windows\System32\WindowsPowerShell\v1.0 for the 64bit environment

  • C:\Windows\SysWow64\WindowsPowerShell\v1.0 for the 32bit one (Yeah I know, the folder naming is counter-intuitive, but it’s
    correct
    ).

answered Sep 9, 2023 at 14:12

:/>  Конвертация FAT32 в NTFS | Сеть без проблем

harrymc's user avatar

No, cmdlets like winget and other powershell modules install themselves inside your powershell modules folder. After you run import-module <name> that module’s commands can now be used. Commands are just functions.

function MyFunction()
{ write-host "MyFunction was executed."
}

And save this in the path found before as a *.psm1 file where the * is replaced with anything you desire of course.

I haven’t found the need to actually write my own modules and I did end up just creating the functions inside my profile.ps1, so I’m not entirely sure what the location is to auto-load your modules, and if you need to add a .psd1 file next to the module for it to work.

This answer is just for you to know how else to do it, if using a profile.ps1 is out of the question.

answered Sep 9, 2023 at 15:38

LPChip's user avatar

10 gold badges101 silver badges146 bronze badges