Closed pikumar closed 8 months ago
Thank you for your suggestion and feedback.
I've recently added bash, fish and zsh autocompletions #198 which will complete the type names for you. So typing -tPy
TAB should work to complete to -tPython
. The repo download has them. I will release an update that includes the new bash, fish and zsh completions soon.
Note that type Python
matches both the filename suffix .py
and also Python "magic bytes", versus python
that only matches the file name suffix .py
.
If you just want to just match filename suffix(es), then -Opy
is the simplest option to use.
Hope this helps.
One additional possibility is to let -t
(--file-type
) also accept a filename extension that is listed under -t list
, then use this extension as an alias for the full lower-case type name. So -t py
is an alias for -t python
(but not for -t Python
perhaps?) There is a slight possibility of two types sharing the same filename extension, making this choice ambiguous. Ambiguous cases should be rejected as aliases. For example, -t h
is ambiguous for C or C++ header file.
The updated -t
option shortcut with filename extensions like -tpy
is included in release v4.4.0.
One more quick thought on this. Perhaps we can also allow a type prefix to match, like -tPy
will be a shorthand for -tPython
. This would only be valid if the specified prefix is unambiguous. So for example-tp
is not valid, since several types start with p
, but -tc
is valid, because it specifies a full type name c
and also -tpy
is valid because only one type name starts with py
. We can still also associate filename extensions with type names, as we just did for v4.4, as a last resort to find a suitable type. This would be the most flexible and "smart" approach. I have played with this and I don't see a downside to this, since types will not change in the future and very few, if any, additional types can be expected. Nevertheless, for scripting I recommend using the full type name to avoid any potential ambiguous type name prefix conflicts in the long run (who knows?).
Please consider supporting "py" along with "Python" Instead of saying ug -tPython PATTERN, I would like to say "ug -tpy PATTERN"
Could I say ug PATTERN *.py and ug knows that I want to recursively only look at python files. (Maybe it conflicts with how others use it - I don't know)
Thanks for ug!