周凯,个人博客

  • 前端
  • 嵌入式
  • 工具
  • 后端
  • 随笔
个人记录
  1. 首页
  2. windows
  3. 正文

Windows Terminal配置 美化

2024年 3月 16日 882点热度 0人点赞 0条评论
  • Windows 终端自定义提示符设置 | Microsoft Learn

安装

  • 在powerShell 开启远程权限

    Set-ExecutionPolicy RemoteSigned -scope CurrentUser
  • scoop

    • 执行 iwr -useb https://gitee.com/glsnames/scoop-installer/raw/master/bin/install.ps1 | iex

    • 如果报错提示:Running the installer as administrator is disabled by default, see https://github.com/ScoopInstaller/Install#for-admin for details.

    • 取消 "默认情况下禁用以管理员身份运行安装程序" iex "& {$(irm get.scoop.sh)} -RunAsAdmin"

    • 设置国内镜像

    scoop config SCOOP_REPO 'https://gitee.com/glsnames/scoop-installer'
    • 更新

配置文件

  • 安装插件

    1. 安装 PSReadline 插件,可以查看历史命令,类似 zsh的incr插件

    Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck

    1. 安装 posh-git 插件,Posh-git 将 Git 状态摘要添加到 Windows 终端提示中,其中包含 Git 命令、参数、远程和分支名称的信息和选项卡完成。

    Install-Module posh-git -Scope CurrentUser

    1. 安装 oh-my-posh 插件,这个插件能够使用全彩色集来定义和呈现您的终端提示,包括使用内置主题或创建您自己的自定义主题的能力。
    Install-Module oh-my-posh
    1. ls 显示彩色目录

      dircolors 是 Linux 下的命令,可以设置 ls 指令在显示目录或文件时的色彩,同样的,如果也想让 PowerShell 显示彩色目录,可用插件 DirColors 实现。

      Install-Module DirColors

    若是有提示输入A

  • 安装oh-my-post

    winget install JanDeDobbeleer.OhMyPosh -s winget

  • 打开配置文件

    notepad $PROFILE
#插件导入
Import-Module posh-git

Import-Module oh-my-posh

Import-Module PSReadLine

Import-Module DirColors

#快捷键设置

# 设置主题
Set-PoshPrompt Agnoster 
# 设置预测文本来源为历史记录
Set-PSReadLineOption -PredictionSource History

# 每次回溯输入历史,光标定位于输入内容末尾
Set-PSReadLineOption -HistorySearchCursorMovesToEnd

# 设置 Tab 为菜单补全和 Intellisense
Set-PSReadLineKeyHandler -Key "Tab" -Function MenuComplete

# 设置 Ctrl+d 为退出 PowerShell
Set-PSReadlineKeyHandler -Key "Ctrl+d" -Function ViExit

# 设置 Ctrl+z 为撤销
Set-PSReadLineKeyHandler -Key "Ctrl+z" -Function Undo

# 设置向上键为后向搜索历史记录
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward

# 设置向下键为前向搜索历史纪录
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward

# 设置主题
oh-my-posh init pwsh --config ~/jandedobbeleer.omp.json | Invoke-Expression

function proxy{
    $env:all_proxy="http://127.0.0.1:7890"
}

function noproxy{
    $env:unsetproxy=""
}
  • 初始化主题

    oh-my-posh init pwsh --config 'https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/atomic.omp.json' | Invoke-Expression
  • 配置字体

    • 字体下载:Nerd Fonts - Iconic font aggregator, glyphs/icons collection, & fonts patcher

  • 使用 Terminal-Icons 添加缺少的文件夹或文件图标

    Install-Module -Name Terminal-Icons -Repository PSGallery

settings.json

  • 打开json文件

  • 添加毛玻璃效果

    在 profiles->defaults下添加

    // 开启毛玻璃效果
    "useAcrylic":true,
    // 毛玻璃透明度
    "acrylicOpacity":0.5,

🎯 拓展阅读提示

本文涉及的内容已同步至公众号后台,我会在那里分享更多深度内容和实用技巧

→ 点击关注:一行梦境

公众号二维码
本作品采用 知识共享署名 4.0 国际许可协议 进行许可
标签: 暂无
最后更新:2024年 3月 18日

周凯

这个人很懒,什么都没留下

打赏 点赞
< 上一篇

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2022-现在 周凯,个人博客. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

蒙ICP备18004897号