This will ensure compatibility with other tools that emit or handle ANSI escape sequences. Since ANSI escape sequences are de facto standardized, we should not introduce a new intermediate format and should just embed ANSI escape sequences within strings. So for PowerShell, we should have a consistent experience regardless if Windows, Linux, or macOS and interop with native commands that may output ANSI escape sequences in addition to cmdlets/formatting. I believe ls on macOS is detecting if output is redirected and turning off coloring automatically. On macOS, the similar command is ls -G, however, piping this output to less or redirecting to a file you lose the ANSI escape sequences so it is just plain text. If you then use the cat command on the file, you see the coloring as the ANSI escape sequences are rendered by the terminal. If you redirect this output to a file, that file contains the ANSI escape sequences. If you pipe this output to less, then you get paging while retaining the color information. On Linux, if you use ls -color then different file types use ANSI escape sequences as color indicators. ![]() Also, for those wanting to leverage ANSI escape sequences, they are difficult to create/read for scripters and also harder to use formatting presets rather than hardcoding specific colors. Since we've added more ANSI escape sequences for coloring in PS7, if you pipe or redirect that text output, the embedded ANSI escape sequences are sent down the pipeline.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |