powershell@Get-ChildItem美化@ls文件列表文件图标样式和配色@Terminal-icons@lsd

本文介绍了如何在PowerShell中使用Terminal-Icons和lsd模块来美化文件列表,包括安装、配置和自定义颜色。Terminal-Icons模块通过显示图标增强终端视觉效果,而lsd提供了跨平台的彩色目录列表。同时,文章还提到了PScolor模块的用法和自定义颜色方案的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

abstract

  • powershell上的美化
  • 文件列表的图标化

预览效果

  • 在这里插入图片描述

Terminal-Icons模块👺

字体推荐

  • 文档指出,需要下载Nerd Font字体才能正确显示图标
  • 并且,尤其推荐 LiberationMono
  • 有些用户比较顺利,随便一个Nerd Font字体就能工作

安装和用法

Installation
Install-Module -Name Terminal-Icons -Repository PSGallery
  • You can also install it from Scoop:
scoop bucket add extras
scoop install terminal-icons
Usage
  • 导入模块

  • 使用ls查看文件或子目录列表效果

    • Import-Module -Name Terminal-Icons
      
      Get-Item ./README.md
      
      Get-ChildItem
      
      Get-ChildItem | Format-List
      
      Get-ChildItem | Format-Wide
      
  • 相关命令

CommandDescription
Add-TerminalIconsColorThemeAdd a Terminal-Icons color theme for the current user.
Add-TerminalIconsIconThemeAdd a Terminal-Icons icon theme for the current user.
Format-TerminalIconsPrepend a custom icon (with color) to the provided file or folder object when displayed.
Get-TerminalIconsColorThemeList the available color themes.
Get-TerminalIconsIconThemeList the available icon themes.
Get-TerminalIconsThemeGet the currently applied color and icon theme.
Remove-TerminalIconsThemeRemoves a given icon or color theme.
Set-TerminalIconsColorThemeDEPRECATED Set the Terminal-Icons color theme.
Set-TerminalIconsIconThemeDEPRECATED Set the Terminal-Icons icon theme.
Set-TerminalIconsThemeSet the Terminal-Icons icon and/or color theme.
Show-TerminalIconsThemeList example directories and files to show the currently applied color and icon themes.
  • 例如Show-TerminalIconsTheme可以列出所有图标

跨平台的lsd👺

其他模块

PScolor模块

  • 在这里插入图片描述

默认情况下

  • 目录为蓝绿色
  • 文本文件为金黄色
  • 二进制文件为灰色
  • 隐藏目录为黑色

Get-ChildItemColor

安装过程
PS C:\Windows\System32> Install-Module -AllowClobber Get-ChildItemColor

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y

自定义颜色

res
  • [Change PowerShell console syntax highlighting colors of PSReadLine – 4sysops](https://4sysops.com/wiki/change-powershell-console-syntax-highlighting-colors-of-psreadline/#:~:text=And if you want to replace the red,Blue%2C Green%2C Cyan%2C Red%2C Magenta%2C Yellow%2C and White.)

    • 获取颜色查看模块:Install-Module -Name TMOutput
      • 执行help TMOutput尝试获取相关命令
      • 发现执行show-TMoutputColor可以获取颜色列表
  • github文档有相关的讨论,不过有人反馈方法不生效,我稍加测试,

    • 发现变量$GetChildItemColorTable已经变化了

      • PS D:\repos\web\webLearn> $GetChildItemColorTable
        
        Name                           Value
        ----                           -----
        File                           {.sh, .rb, .fasl, .cdxml…}
        Match                          {LineNumber, Default, Line, Path}
        Service                        {Stopped, Default, Running}
        
      • PS D:\repos\web\webLearn> $GetChildItemColorTable.File|head
        
        Name                           Value
        ----                           -----
        .sh                            Green
        .rb                            DarkYellow
        .fasl                          DarkYellow
        .cdxml                         DarkYellow
        .dll                           DarkGreen
        .css                           DarkYellow
        .bat                           Green
        
默认的文件颜色种类分布
PS C:\Users\cxxu> $GetChildItemColorTable.File.Values|group
                                                                                           Count Name                      Group
----- ----                      -----
    1 Blue                      {Blue}
    1 Cyan                      {Cyan}
    2 DarkGreen                 {DarkGreen, DarkGreen}
  104 DarkYellow                {DarkYellow, DarkYellow, DarkYellow, DarkYellow…}
    6 Gray                      {Gray, Gray, Gray, Gray…}
    6 Green                     {Green, Green, Green, Green…}
    5 Red                       {Red, Red, Red, Red…}
    6 Yellow                    {Yellow, Yellow, Yellow, Yellow…}


  • (该变量类型是hashtable)
    • 检测方法:$GetChildItemColorTable|gm,第一行将提示变量类型
  • $GetChildItemColorTable.File[".html"]="Magenta"

下图中,左侧是可用的颜色参考(名称和对照);右侧展示大概的修改方法(临时)

如果想要永久修改,将语句收集,并写入$profile文件中(如果没有则创建之)

在这里插入图片描述

自动导入并启用着色模块

### 大模型对齐微调DPO方法详解 #### DPO简介 直接偏好优化(Direct Preference Optimization, DPO)是一种用于改进大型语言模型行为的技术,该技术通过结合奖励模型训练强化学习来提升训练效率与稳定性[^1]。 #### 实现机制 DPO的核心在于它能够依据人类反馈调整模型输出的概率分布。具体来说,当给定一对候选响应时,DPO试图使更受偏好的那个选项具有更高的生成概率。这种方法不仅简化了传统强化学习所需的复杂环境设置,而且显著增强了模型对于多样化指令的理解能力执行精度[^2]。 #### PAI平台上的实践指南 为了便于开发者实施这一先进理念,在PAI-QuickStart框架下提供了详尽的操作手册。这份文档覆盖了从环境配置直至完成整个微调流程所需的一切细节,包括但不限于数据准备、参数设定以及性能评估等方面的内容。尤其值得注意的是,针对阿里云最新发布的开源LLM——Qwen2系列,文中给出了具体的实例说明,使得即使是初次接触此类工作的用户也能顺利上手。 ```python from transformers import AutoModelForCausalLM, Trainer, TrainingArguments model_name_or_path = "qwen-model-name" tokenizer_name = model_name_or_path training_args = TrainingArguments( output_dir="./results", per_device_train_batch_size=8, num_train_epochs=3, ) trainer = Trainer( model_init=lambda: AutoModelForCausalLM.from_pretrained(model_name_or_path), args=training_args, train_dataset=train_dataset, ) # 假设已经定义好了train_dataset trainer.train() ``` 这段代码片段展示了如何使用Hugging Face库加载预训练模型并对其进行微调的过程。虽然这里展示的例子并不完全对应于DPO的具体实现方式,但它提供了一个基础模板供进一步定制化开发之用[^3]。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

cxxu1375

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值