beyondgrep / ack3

ack is a grep-like search tool optimized for source code.
https://beyondgrep.com/
Other
713 stars 66 forks source link

Support ".ps1" PowerShell file type #362

Closed thgossler closed 1 year ago

thgossler commented 2 years ago

Please add PowerShell .ps1 to the known file types.

petdance commented 2 years ago

Please point to the docs for it. Are there other extensions that might need to go with it? Are there any potential collisions with other files called .ps1 we should know about?

thgossler commented 2 years ago

PowerShell uses only the following defined extensions:

.ps1 => scripts (https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scripts?view=powershell-7.2)

.psm1 => modules (https://learn.microsoft.com/en-us/powershell/scripting/developer/module/understanding-a-windows-powershell-module?view=powershell-7.2)

.psd1 => module manifest (https://learn.microsoft.com/en-us/powershell/scripting/developer/module/understanding-a-windows-powershell-module?view=powershell-7.2#module-manifests)

These extensions have no dependencies to other file types and should be unique as well.

petdance commented 2 years ago

So if you were to do ack foo --powershell, which of those files would you expect it to search? .ps1 only? .ps1 and .psm1?

Either way, make yourself an .ackrc file in your home directory, if you don't have one already, and add one of these two lines:

--type-add=powershell:ext:ps1

or

--type-add=powershell:ext:ps1,psm1

Then you'll have --powershell support. Ue it for a while and see how it works out.

We need someone to try it out before we make it official in ack itself.

thgossler commented 2 years ago

Thanks! Yes, I found the option to extend the config myself via .ackrc file or command line. This is great.

Still, it would be nice to have it supported out of the box.

Actually, I would expect .ps1 and .psm1 files to be searched (both contain relevant PS code), but not .psd1.

petdance commented 2 years ago

So have you been using the config aliases for a while? How long? With both ps1 and psm1 and not psd1?

it would be nice to have it supported out of the box.

Understood. I'm basically asking you to be a beta tester for this change. Maybe you'll turn up some sort of problem.

petdance commented 1 year ago

Done at f18e96a