Document the $PSStyle.HumanReadable settings for human-readable file sizes and timestamps (PowerShell 7.8)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 82/100
- Issue 类型
- 文档
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- powershell
调研方向
从 issue 中提到的 PowerShell 7.8 参考页面开始:about_ANSI_Terminals.md 和 Get-ChildItem.md。记录 $PSStyle.HumanReadable 的三个设置、它们的默认值和效果,并说明如何恢复原始字节数;7.8 文件夹可用后,更新引用的目录列表示例。参考页面描述了该行为且示例反映了新的默认值时,工作即告完成。
由索引模型根据 Issue 内容生成。
描述
Prerequisites
- Existing Issue: Searched the existing issues for this repository; there is no issue covering the new
$PSStyle.HumanReadablemembers (the closed issues only coverAutoSizeDefaultFormatting,CustomTableHeaderLabel, andProgress.View). - Descriptive Title: See above.
Summary
PowerShell is adding a $PSStyle.HumanReadable nested settings object in PowerShell 7.8 that controls whether certain formatted values are rendered in human-readable form. The documentation needs to cover the three boolean settings and their defaults — most importantly that the Length column of directory listings (Get-ChildItem / Get-Item) now shows sizes like 820.1 MB or 1.1 TB instead of raw byte counts by default, and how to restore the previous display.
Details
The feature was requested in PowerShell/PowerShell#24011 (with the Working Group decision defining the $PSStyle.HumanReadable surface) and is implemented in PowerShell/PowerShell#28468 (targeting master, so it ships in PowerShell 7.8 - it is not part of the released PowerShell 7.7). Design proposals that informed the formatting choices are in kilasuit/PowerShell#171.
$PSStyle.HumanReadable has three boolean properties:
-
Size (default
$true): file sizes in directory listings render in compact binary (1024-based) units with at most one (truncated) decimal digit, similar to Windows File Explorer:# PowerShell 7.7 and earlier # PowerShell 7.8 (default) Mode LastWriteTime Length Mode LastWriteTime Length Name ---- ------------- ------ ---- ------------- ------ ---- -a--- 04/07/2024 01:36 859832320 -a--- 04/07/2024 01:36 820.1 MB backup.vhdx -a--- 04/07/2024 01:35 776 -a--- 04/07/2024 01:35 776 B BackupSpecs.xml -a--- 04/07/2024 01:36 1298450612224 -a--- 04/07/2024 01:36 1.1 TB disk.vhdx -
Datetime (default
$false): when enabled, theLastWriteTimecolumn renders relative timestamps -just now(less than a minute),5 min ago(less than an hour),19 hours ago(less than a day),6 days ago(less than 7 days). Values older than 7 days, or in the future, fall back to the existing culture-aware short date and time format. -
Timespan (default
$false): reserved for follow-up work onSystem.TimeSpanviews; currently has no effect.
Behavior worth documenting:
- The setting is honored at render time; changing it takes effect immediately without reloading format data.
- Only display formatting is affected - the
Length(Int64) andLastWriteTime(DateTime) properties ofFileInfoobjects are unchanged, so scripts that read the properties are unaffected. - Files not on disk (
FileAttributes.Offline) keep the existing parentheses convention, now humanized:(2 KB). - Setting
$PSStyle.HumanReadable.Size = $falserestores the raw byte count display of earlier versions. - The default formatted view of
$PSStylelists the new settings (HumanReadable.Size,HumanReadable.Datetime,HumanReadable.Timespan).
Articles
The reference updates target the reference/7.8 version folder, which is created upstream when the PowerShell 7.8 preview documentation cycle begins:
- about_ANSI_Terminals (
reference/7.8/Microsoft.PowerShell.Core/About/about_ANSI_Terminals.md) - the$PSStyledeep dive - Get-ChildItem (
reference/7.8/Microsoft.PowerShell.Management/Get-ChildItem.md)
In addition, examples elsewhere in the docs that show Get-ChildItem output with raw byte counts render differently under the new default (for example, the $WhatIfPreference examples in about_Preference_Variables show 10 test.txt in the Length column, which now displays as 10 B). These example outputs can be refreshed when the 7.8 version folder is created.
Suggested updates
- Add
HumanReadableto the bulleted property list of$PSStylein about_ANSI_Terminals, noting it was added in PowerShell 7.8. - Add a
$PSStyle.HumanReadabledetail block to about_ANSI_Terminals alongside the existingAutoSizeDefaultFormatting/Formatting/FileInfoblocks (suggested content below). - Add a note to the OUTPUT section of Get-ChildItem (and optionally Get-Item) that file sizes are displayed in human-readable format by default and can be restored to raw byte counts with
$PSStyle.HumanReadable.Size = $false. - Refresh example outputs that show directory listings with raw byte counts when creating the 7.8 version folder.
Suggested content
New entry for the $PSStyle property list in about_ANSI_Terminals:
- HumanReadable - Nested object that controls whether values such as file sizes and timestamps are rendered in a human-readable format (added in PowerShell 7.8)
New detail block for about_ANSI_Terminals:
$PSStyle.HumanReadableis a nested object that controls whether certain
values are rendered in a human-readable format.
- Size - A boolean, defaults to
$true. When enabled, file sizes in
directory listings (such asGet-ChildItemandGet-Item) are displayed
in compact binary units, for example745 B,16.7 KB,820.1 MB, or
1.1 TB, instead of raw byte counts. Files that aren't available on disk
are shown with their size in parentheses, for example(2 KB). Set this
to$falseto restore the raw byte count display. This only affects
formatting; the Length property of FileInfo objects is unchanged.- Datetime - A boolean, defaults to
$false. When enabled, timestamps
in directory listings (such as the LastWriteTime column) are rendered
as relative values, for examplejust now,5 min ago,19 hours ago,
or6 days ago. Values older than 7 days, or in the future, are rendered
using the culture-aware short date and time format.- Timespan - A boolean, defaults to
$false. Reserved for future use;
currently has no effect.The following example restores the raw byte count display of PowerShell
7.7 and earlier:$PSStyle.HumanReadable.Size = $false
Note for the OUTPUT section of Get-ChildItem:
[!NOTE]
Beginning in PowerShell 7.8, file sizes in the default directory listing
are displayed in a human-readable format (for example1.1 TB). To display
the raw byte count, set$PSStyle.HumanReadable.Sizeto$false. For more
information, see about_ANSI_Terminals.
Related Source Pull Requests
Related Source Issues
- 主要语言
- PowerShell
- 星标
- 2.6k
- 派生
- 1.7k
- 平均合并
- 3 小时 49 分钟
- 30 天内合并 PR
- 5
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
MicrosoftDocs/PowerShell-Docs 的其他 Issue
-
难度 1/5 1-3 小时 新手友好度 88/100
MicrosoftDocs/PowerShell-Docs#13431 ·
维护者通常 1 天内回复
-
about_Logging_Windows: registry example creates EnableScriptBlockLogging as a string, which PowerShell 7 ignores可能已有人在做 @CHX606 今天认领。 未关闭needs-triage
难度 2/5 1-3 小时 新手友好度 90/100
MicrosoftDocs/PowerShell-Docs#13423 ·
维护者通常 1 天内回复
-
needs-triage
难度 1/5 1 小时以内 新手友好度 68/100
MicrosoftDocs/PowerShell-Docs#13419 ·
维护者通常 1 天内回复
-
issue-doc-bug needs-triage
难度 2/5 1-3 小时 新手友好度 68/100
MicrosoftDocs/PowerShell-Docs#13413 ·
维护者通常 1 天内回复
-
Rename-Item: Tell about NewName parameter allow scriptBlock可能已有人在做 @gerardrecinto 于 1 天前认领。 未关闭needs-triage
难度 1/5 1 小时以内 新手友好度 88/100
MicrosoftDocs/PowerShell-Docs#13412 ·
维护者通常 1 天内回复
查看 MicrosoftDocs/PowerShell-Docs 的全部 Issue
相似的 Issue
-
enhancement good first issue help wanted
难度 1/5 1-3 小时 新手友好度 92/100
-
area:cli area:docs Platform vdr
难度 2/5 1-3 小时 新手友好度 78/100
NVIDIA-NeMo/Gym#7192 ·
维护者通常 2 天内回复
-
Document lexicon.default.userconfig and lexicon.default.userconfig.enforced in config.sample.php未关闭enhancement feature: settings good first issue
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
open-telemetry/semantic-conventions-client-side#72 ·
维护者通常 1 天内回复
-
area: cli area: repo priority: P3 type: chore
难度 2/5 1-3 小时 新手友好度 84/100
appandflow/stim#6826 ·
维护者通常 1 天内回复