-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Add support to colorize FileInfo file names #14403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
59461d2
to
dde70a2
Compare
Codefactor issues are existing ones |
@SteveL-MSFT I am very concerned that we are colorizing many things by default. This is a very sensitive area for many people. I think we need themes support and the default theme needs to be approved by MSFT accessibility team. |
@iSazonov from an accessibility standpoint, the rule that applies here is sufficient contrast between colors (foreground and background) which is covered by the default selections. Can certainly add a Let's continue the discussion in the issue #9270 |
My eyes can hold up quite well all day with the classic Windows soothing color style, but they will definitely be against the checkered color scheme.
As I mentioned early, $PSStyle should be evaluated based on TermInfo, and we need to map $PSStyle to TermInfo - the mapping I named |
@Jaykul, this PR makes changes to FileSystemProvider to make it as fast as possible. Certainly it's feasible to call a native POSIX API to determine if a file on Linux/macOS is an executable or call a win32 API to check if an object is a reparse point and obtain the target within a format ps1xml, but it would be much more code. |
src/System.Management.Automation/namespaces/FileSystemProvider.cs
Outdated
Show resolved
Hide resolved
I missed that Ignoring who wrote this code, the PowerShell team pledged that feature requests would be aggressively rejected if they can be done externally, and this has, in fact, already been done multiple times in modules. Just for example:
Many of these modules do far more than just color files, and have spawned their own copy cats and even modules which depend on them. The two I picked do things in a Windows-specific way (i.e. coloring files by extension) --they're the ones I've personally used in the past-- but a module can easily duplicate a PInvoke or two and implement this in more cross-platform way, and still ship externally so as to not end up doing the work twice (and breaking the other modules if the experimental flag is ever removed). Building this into PowerShell also adds a lot of maintenance, because it will mean that this repo and team are going to get requests for every other type of coloring of Get-ChildItem output which you may have forgotten, including requests to add icons, to support the In my opinion this should not be merged. I do think the functionality to check |
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs
Outdated
Show resolved
Hide resolved
@Jaykul I would agree that anything more than what is provided here would make sense to provide as a module. The intent here is only parity with |
…eatures cannot contain a period
Created discussion for partial format updates to support other PSColor and Terminal-Icon scenarios #15746 |
@PowerShell/powershell-committee discussed this at length today, and many of us agreed that you made some excellent points in this thread, @Jaykul. In particular, we empathize with your point about our stance to push innovation happening out of the PS repo vs. within the repo, and that's certainly the general case. However, the original experimental feature-- Now, to your point, there's very cool stuff happening in other modules like Another reason for shipping this work is to validate that the To all those ends, we're going to merge this as experimental, but we'll still evaluate it as any other experimental feature before we promote it to stable. I believe that @SteveL-MSFT also plans to write an RFC for all the As a personal side note, I'd like to do some further analysis of the default colors before shipping as stable as well. @SteveL-MSFT took these straight from |
Standard? This standard is so old that you won't surprise anyone. PowerShell was approved and came into being only because it was a next generation shell with great innovations. Don't you have any breakthrough ideas at all? What about Jason's PSMore for next dynamic formatting? Jim's DSL? New modern remoting? There are others lost in the midst of several thousand issues. Some interesting ideas seem to have been started but forgotten. PowerShell Core is celebrating its fifth anniversary and we have to ask where are the unparalleled innovations?
You could open Notepad and try colorize - on the second entity you will feel sorry for your time and the bloated XML will horrify you :-)
It makes no sense to spend time on coping old school semi-features (especially if there are already alternative modules). |
src/System.Management.Automation/FormatAndOutput/common/PSStyle.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/FormatAndOutput/common/PSStyle.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Yay, many thanks for this @SteveL-MSFT ! |
🎉 Handy links: |
In case anyone else comes here after installing
It makes directories use standard colors but they are underlined and bold. |
PR Summary
Built on
PSAnsiRendering
experimental feature to enable coloring of specific file types. Example:Adds
FileInfo
member to$PSStyle
automatic variable to allow customization.Directory
,SymbolicLink
, andExecutable
are built-in, but anExtension
member which is a dictionary allows modification and addition of new extensions and custom styles. Leverages existingNameString
extended member for coloring. Pre-included extensions for archives and PowerShell files. Default color choices are mostly consistent withls --color
.PR Context
Fix #9270
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.PSAnsiRenderingFileInfo