Windows 终端美化 PowerShell 默认终端修改


网上各种各样的美化方法操作起来十分麻烦
可以写好脚本完成配置

在这里插入图片描述
可以直接在microsoft store 中搜索PowerShell,完成基本的安装。

以下开始美化PowerShell。

所有的命令都是在管理员模式下执行

安装 oh-my-posh

首先确保安装git

Install-Module posh-git -Scope CurrentUser git

然后安装「oh-my-posh」

Install-Module oh-my-posh -Scope CurrentUser

弹出安装选项时,输入y或者a。

安装Powerline字体

安装方法要用到git。Win+X然后再按A,启动powershell管理员模式。执行代码:

# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.ps1

安装ConEmu

ConEmu相当于windows终端的增强版,可以直接打开多种类型的控制台窗口,之后我们安装完了会用他替换powershell,没关系,调试好以后使用感觉一定比原版powershell好。

choco install ConEmu

美化powershell

接下来在「PowerShell」执行以下命令检测并初始化 「Profile」 文件(类似 「Linux bash」 中的.bashrc 文件)保存我们的配置:

if (!(Test-Path -Path $PROFILE )) {
    
     New-Item -Type File -Path $PROFILE -Force }

显示默认路径,我的路径是下面这样

C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

在这里插入图片描述
然后双击箭头文件,或者输入

notepad $PROFILE

打开文件,将下面的内容粘贴进去

Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Agnoster

保存文件后,以管理员权限重新打开powershell,开始自动安装。
在这里插入图片描述
遇到选项选择y或者a。

如果报错
git command could not be found. Please create an alias or add it to your PATH.
请先安装Git for Windows
安装后即可解决
下载这个非常困难,国内下载地址:
https://npm.taobao.org/mirrors/git-for-windows/v2.26.0.windows.1/

设置ConEmu

设置很简单。打开ConEmu,右键上方栏位,选择setting:

在这里插入图片描述
在这里插入图片描述

把界面默认语言改为中文简体

在这里插入图片描述

设置默认启动shell为powershell

当然你也可以选择别的,例如管理员模式
在这里插入图片描述

设置powershell为默认shell

在这里插入图片描述


或者可以直接在安装powershell后执行脚本。

脚本下载链接

猜你喜欢

转载自blog.csdn.net/wangyifan123456zz/article/details/109539506