0
点赞
收藏
分享

微信扫一扫

Windows Terminal配置 美化

49路末班车 03-24 06:00 阅读 3
  • Windows 终端自定义提示符设置 | Microsoft Learn

安装PowerShell7

  • 在 Windows 上安装 PowerShell - PowerShell | Microsoft Learn

  • 设置默认为 PowerShell7

    在这里插入图片描述

安装

  • 在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,
    
举报

相关推荐

0 条评论