mirror of
https://github.com/Leonmmcoset/CMLeonOS.git
synced 2026-04-21 19:24:00 +00:00
ls命令增强
This commit is contained in:
@@ -1 +1 @@
|
|||||||
2026-03-14 21:51:05
|
2026-03-15 13:19:36
|
||||||
@@ -1 +1 @@
|
|||||||
fbb90da
|
d44fca8
|
||||||
@@ -166,7 +166,11 @@ namespace CMLeonOS
|
|||||||
foreach (var file in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
string fileName = Path.GetFileName(file);
|
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.WriteLine($"[FILE] {fileName}");
|
||||||
Console.ResetColor();
|
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<string> GetFileList(string path = ".")
|
public List<string> GetFileList(string path = ".")
|
||||||
{
|
{
|
||||||
string fullPath = GetFullPath(path);
|
string fullPath = GetFullPath(path);
|
||||||
|
|||||||
@@ -126,6 +126,25 @@ ls
|
|||||||
ls /system
|
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
|
### cd
|
||||||
切换当前工作目录。
|
切换当前工作目录。
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user