diff --git a/BuildTime.txt b/BuildTime.txt index 18a4305..b192597 100644 --- a/BuildTime.txt +++ b/BuildTime.txt @@ -1 +1 @@ -2026-03-14 21:51:05 \ No newline at end of file +2026-03-15 13:19:36 \ No newline at end of file diff --git a/GitCommit.txt b/GitCommit.txt index d9996bc..c52705e 100644 --- a/GitCommit.txt +++ b/GitCommit.txt @@ -1 +1 @@ -fbb90da \ No newline at end of file +d44fca8 \ No newline at end of file diff --git a/System/FileSystem.cs b/System/FileSystem.cs index b5018cd..ca0e873 100644 --- a/System/FileSystem.cs +++ b/System/FileSystem.cs @@ -166,7 +166,11 @@ namespace CMLeonOS foreach (var file in files) { string fileName = Path.GetFileName(file); - Console.ForegroundColor = ConsoleColor.White; + string extension = Path.GetExtension(fileName)?.ToLower(); + + ConsoleColor fileColor = GetFileColor(extension); + + Console.ForegroundColor = fileColor; Console.WriteLine($"[FILE] {fileName}"); Console.ResetColor(); } @@ -190,6 +194,47 @@ namespace CMLeonOS } } + private ConsoleColor GetFileColor(string extension) + { + if (string.IsNullOrEmpty(extension)) + return ConsoleColor.Gray; + + return extension switch + { + // 这是一堆后缀名的颜色标注,但是许多后缀名还不支持,先保留 + ".exe" => ConsoleColor.Green, + ".cla" => ConsoleColor.Green, + ".lua" => ConsoleColor.Cyan, + ".js" => ConsoleColor.Cyan, + ".py" => ConsoleColor.Cyan, + ".sh" => ConsoleColor.Cyan, + ".bat" => ConsoleColor.Cyan, + ".cmd" => ConsoleColor.Cyan, + ".ps1" => ConsoleColor.Cyan, + ".json" => ConsoleColor.Magenta, + ".xml" => ConsoleColor.Magenta, + ".ini" => ConsoleColor.Magenta, + ".cfg" => ConsoleColor.Magenta, + ".conf" => ConsoleColor.Magenta, + ".txt" => ConsoleColor.White, + ".md" => ConsoleColor.White, + ".rtf" => ConsoleColor.White, + ".bmp" => ConsoleColor.Blue, + ".png" => ConsoleColor.Blue, + ".jpg" => ConsoleColor.Blue, + ".jpeg" => ConsoleColor.Blue, + ".gif" => ConsoleColor.Blue, + ".zip" => ConsoleColor.Red, + ".rar" => ConsoleColor.Red, + ".7z" => ConsoleColor.Red, + ".tar" => ConsoleColor.Red, + ".gz" => ConsoleColor.Red, + ".mi" => ConsoleColor.DarkYellow, + ".dat" => ConsoleColor.DarkBlue, + _ => ConsoleColor.Gray + }; + } + public List GetFileList(string path = ".") { string fullPath = GetFullPath(path); diff --git a/docs/cmleonos/docs/commands.md b/docs/cmleonos/docs/commands.md index c6c9737..265409f 100644 --- a/docs/cmleonos/docs/commands.md +++ b/docs/cmleonos/docs/commands.md @@ -126,6 +126,25 @@ ls ls /system ``` +**颜色标注:** +- 黄色:目录 +- 绿色:可执行文件 +- 青色:脚本文件 +- 紫色:配置文件 +- 白色:文本文件 +- 蓝色:图片文件 +- 红色:压缩文件 +- 深黄色:Markit文件 +- 灰色:其他文件 + +**文件类型对应:** +- 可执行文件:.exe, .cla +- 脚本文件:.lua, .js, .py, .sh, .bat, .cmd, .ps1 +- 配置文件:.json, .xml, .ini, .cfg, .conf +- 文本文件:.txt, .md, .rtf +- 图片文件:.bmp, .png, .jpg, .jpeg, .gif +- 压缩文件:.zip, .rar, .7z, .tar, .gz + ### cd 切换当前工作目录。