Skip to content
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

Feature Request: Color output of gci #9270

Closed
musm opened this issue Apr 1, 2019 · 19 comments · Fixed by #14403
Closed

Feature Request: Color output of gci #9270

musm opened this issue Apr 1, 2019 · 19 comments · Fixed by #14403
Assignees
Labels
Issue-Enhancement the issue is more of a feature request than a bug WG-Engine core PowerShell engine, interpreter, and runtime
Projects
Milestone

Comments

@musm
Copy link

musm commented Apr 1, 2019

Summary of the new feature/enhancement

Add colored output so when performing gci we have an output that is similar to the colored output in a linux shell.

Proposed technical implementation details (optional)

https://github.com/joonro/Get-ChildItemColor

@musm musm added the Issue-Enhancement the issue is more of a feature request than a bug label Apr 1, 2019
@iSazonov
Copy link
Collaborator

iSazonov commented Apr 2, 2019

We could track this in #7857 PSMore.

@iSazonov iSazonov added the WG-Engine core PowerShell engine, interpreter, and runtime label Apr 2, 2019
@musm
Copy link
Author

musm commented Apr 8, 2019

Is the PSMore project actively maintained any more ? It seems not.

@iSazonov
Copy link
Collaborator

iSazonov commented Apr 9, 2019

@musm This project is not even started.

@musm
Copy link
Author

musm commented Oct 28, 2019

Bump, it doesn't seem like it's activate at all?

@SteveL-MSFT SteveL-MSFT added this to the vNext-Consider milestone Oct 28, 2019
@SteveL-MSFT SteveL-MSFT added this to To do in Shell via automation Oct 28, 2019
@SteveL-MSFT
Copy link
Member

We want to wait until we have a consistent way within the engine to support attributed text

@SteveL-MSFT
Copy link
Member

SteveL-MSFT commented Dec 15, 2020

I have an implementation here #14403

image

Does the design look reasonable? Are there other default extensions (with colors/styles) that should be included by default?

Originally I considered supporting images and audio files, but don't necessarily want to add a huge number of entries to the extension hashtable.

@bfoster68
Copy link

Love this idea because readability is paramount

@musm
Copy link
Author

musm commented Dec 15, 2020

Love it. I was never keen on how Ubuntu gives directories a background color, and would be happy if we did not copy that stylistic choice. A distinct foreground color to distinguish folders without a background would be my preference.

@petervandivier
Copy link

Allowing users to configure $PROFILE to customise the colour theme or selectively override defaults for this seems pretty important to me. Even if it's an arcane syntax, the ability to choose (as with $LS_COLORS for example) should be a first-release feature.

@Jaykul
Copy link
Contributor

Jaykul commented Dec 15, 2020

😖 😕 😠

Why are core team members wasting time implementing stuff that's already done
I thought we had pledged to stop implementing things in the core that are easily doable by modules?

@SteveL-MSFT
Copy link
Member

@Jaykul I did this on the weekend on my free time.

@ThomasNieto
Copy link
Contributor

Using ansi escape sequences directly isn't very user friendly or verbose.

I still don't understand why we aren't putting color support directly into the formatting/output layer.

@SteveL-MSFT
Copy link
Member

@ThomasNieto for consoles, ANSI escape sequences ARE the de facto standard. PowerShell needs to work with existing native commands that already output ANSI escape sequences. In this case, the end user does NOT need to work directly with ANSI escape sequences. That is the whole point of $PSStyle. The formatting shows the "raw" ANSI escape sequences for users that understand them, but otherwise they are colored to what would be rendered. If a user wanted to change Directory to be just blue, they would do:

$PSStyle.FileInfo.Directory = $PSStyle.Foreground.Blue

@SteveL-MSFT
Copy link
Member

@ThomasNieto I think you're missing the point of $PSStyle that I described above. Users don't need to understand ANSI escape sequences. If you want red and green in a string in PowerShell script, it would look like:

"$($PSStyle.Foreground.Red)Merry $($PSStyle.Foreground.Green)Christmas"

Or combine multiple styles:

"$($PSStyle.Italic+$PSStyle.Foreground.Yellow+$PSStyle.Background.Magenta)Hello"

With the automatic variable, you also get tab-completion.

@iSazonov
Copy link
Collaborator

Users don't need to understand ANSI escape sequences.

I believe most of users would prefer to pick up a predefined color theme and do not waste time manually setting dozens of parameters.
We could look on other applications. MS Office allows select one from 4 predefined themes. Notepad++ has tens "styles" (aka themes) and embedded editor for them.

@Jaykul
Copy link
Contributor

Jaykul commented Dec 16, 2020

I still don't understand why we aren't putting color support directly into the formatting/output layer.

This is directly in the formatting/output layer. It's modifying the default format.ps1xml (which is in C# now, because it's faster that way)

@MAGOO56
Copy link

MAGOO56 commented Jan 14, 2021

First, I really love this idea! I have two comments:

  1. The leading period in the extension property seems redundant. Could this be left out?
  2. Can wildcarding or simple regex be used to reduce the number of entries? (eg. 'ps1xml1|ps(d|m)?1' toreplace the separate entries ps1, psd1, psm1, and ps1xml1 which have the same setting)

@SteveL-MSFT
Copy link
Member

SteveL-MSFT commented Jul 7, 2021

FileInfo.Extension includes the leading period, so it would be less optimal to exclude it. Allowing a regex will make things slower.

Shell automation moved this from To do to Done Jul 12, 2021
@ghost
Copy link

ghost commented Jul 22, 2021

🎉This issue was addressed in #14403, which has now been successfully released as v7.2.0-preview.8.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug WG-Engine core PowerShell engine, interpreter, and runtime
Projects
Shell
  
Done
Development

Successfully merging a pull request may close this issue.

9 participants